Sunday, March 11, 2012

Reading unicode data through Python

Processing files containing unicode based characters requires using the codec library instead of the standard file processing libraries. The relevant code:


import codecs

file = codecs.open("file_with_unicode_data.txt", "r", "utf-8")
print file.readlines()
file.close()

No comments:

Post a Comment