Tuesday, July 7, 2009

In python, how to read unicode or GBK files

import codecs

infile=codecs.open(infilename,"r","gbk")

line=infile.readline()

# all the lines which are read from infile are encoded in GBK

No comments: