====== python 编码 检测 ====== 使用 chardet 可以很方便的实现字符串/文件的编码检测 例子如下: >>> import urllib >>> rawdata = urllib.urlopen('http://www.google.cn/').read() >>> import chardet >>> chardet.detect(rawdata) {'confidence': 0.98999999999999999, 'encoding': 'GB2312'} >>> chardet 下载地址 http://chardet.feedparser.org/