Salı, Mart 18, 2008

Writing Unicode Characters in Python

Unicode files and Python



Reading and writing Unicode files from Python is simple. Use
codecs.open() and specify the encoding.



  import codecs
# Open a UTF-8 file in read mode
infile = codecs.open("infile.txt", "r", "utf-8")
# Read its contents as one large Unicode string.
text = infile.read()
# Close the file.
infile.close()

http://www.jorendorff.com/articles/unicode/python.html

Hiç yorum yok: