Skip to content

Latest commit

 

History

History
17 lines (11 loc) · 272 Bytes

chardet.md

File metadata and controls

17 lines (11 loc) · 272 Bytes

chardet

识别字符串编码类型,还能返回识别的准确率

# coding=utf-8

import chardet

source = u'中国'
utf8_source = source.encode('utf-8')
gbk_source = source.encode('gbk')

print chardet.detect(utf8_source)
print chardet.detect(gbk_source)