Unicode output to file

Martin v. Löwis martin at v.loewis.de
Mon Dec 1 01:53:33 EST 2003


=?windows-1251?b?xeLj5e3o6SDK7vHl7eru?= <eugine_kosenko at ukr.net> writes:

> I use here Russian letters, and need special encoding for them. The
> property 'encoding' is read-only, and is None by default. How to
> cast the encoding for a file?

You should use codecs.open instead of the builtin open function; this
allows you to pass an encoding for the file stream.

HTH,
Martin





More information about the Python-list mailing list