UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 99: ordinal not in range(128)
Diez B. Roggisch
deets at nospam.web.de
Sun Nov 6 16:05:39 EST 2005
> I would've thought that the 'b' option meant I can write any binary
> code I like to the file,
> but that's not so?
You can. But if you write a unicode-object (wich is an abstract data
type with no byte representation), it has to be converted to a string -
which you have to do either explicit. Or if you don't do it - it ill be
done automatically, using the system default encoding. Which is ascii,
most of the time.
So do
noteFileObj.write(note.encode("utf-8"))
Regards,
Diez
More information about the Python-list
mailing list