Read text files with a specific encoding? using fileinput?

Boudewijn Rempt boud at valdyas.org
Fri Feb 14 18:06:46 CET 2003


Jim Correia wrote:

> How can I read a test file off disk and interpret it as using a specific
> encoding? (Such as utf-8, iso-latin-1, etc.)
> 

s = codecs.open("filename", "utf-8").read() does the trick.

-- 
Boudewijn Rempt | http://www.valdyas.org




More information about the Python-list mailing list