Unicode File

Martin von Loewis loewis at informatik.hu-berlin.de
Tue Jul 31 07:55:00 EDT 2001


Tksee Lhsoh <tksee at yahoo.com> writes:

> For example,
> s=open("unicode_filename").read();
> seems to return oridinary string, not unicode.
> 
> What should I do ?

I recommend to use codecs.open. You'll need to specify the encoding,
e.g.

s = codecs.open("unicode_filename",encoding="ucs-2").read()

Regards,
Martin




More information about the Python-list mailing list