i need to write some polish text into a new file, so I have tried:
myLines = somePolishText
file = open('myText.txt', 'w')
file.writelines(myLines)
at this point, I've got an error like this:
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0119' in position 29: ordinal not in range(128)
After lots of recharch and findings, I have change the same code like this:
import codecs
myLines = somePolishText
file = codecs.open('myText.txt', 'w', 'utf-8')
file.writelines(myLines)
and its works for me pritty well.
Thanks
Sakib
Friday, May 28, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment