python读取文件编码格式

下载库

pip install chardet

 

执行

import chardet

f = open('a.doc',r)

data = f.read()

print chardet.detect(data)

 

结果

{'confidence': 0.64465744, 'encoding': 'utf-8'}

前面是相似度  后面是编码格式

posted @ 2016-05-28 20:14  为了生活而学习  阅读(12122)  评论(0编辑  收藏  举报