help in code

Ulrich Eckhardt eckhardt at satorlaser.com
Mon Aug 30 06:45:58 EDT 2010


Steven D'Aprano wrote:
[reading Bengali]
> In Python 2, you probably need to do this:
> 
> f = open("filename")
> bytes = f.read()
> text = bytes.decode('which-encoding-you-use')
> f.close()

In Python 2, I'd rather take a look at the "codecs" module (see
http://docs.python.org), namely the "codecs.open" function.

Uli

-- 
Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932




More information about the Python-list mailing list