How to write unicode strings into a file?

you’re going to have to ‘encode’ the unicode string.

s = u'\u5E73\u621015'
with open("yop", "wb") as f:
   f.write(s.encode("UTF-8"))

try this out for a bit of a friendly look at unicode and python: http://farmdev.com/talks/unicode/

Leave a Comment