基本思路,读取文件编码,然后先解码,后转码:
顺序:
取编码 =========》》》 解码 =====================》》》 转码
代码块如下:
取编码:
#read the content
file = open(filename, 'r')
s = file.read()
print chardet.detect(s)['encoding']
file.close()
基本思路,读取文件编码,然后先解码,后转码:
顺序:
取编码 =========》》》 解码 =====================》》》 转码
代码块如下:
取编码:
#read the content
file = open(filename, 'r')
s = file.read()
print chardet.detect(s)['encoding']
file.close()