Py学习  »  Python

python 编码问题

yi4534 • 6 年前 • 1073 次点击  
#encoding='utf-8' 
import tstEncode
import chardet


strsrc = 'abcd在1efg'
rt1= chardet.detect(strsrc)
print rt1

strsrc = strsrc.decode(rt1['encoding'])
strsrc =strsrc.encode('GBK','ignore')
rt1= chardet.detect(strsrc)
print rt1

为什么这个编码会这样: {'confidence': 0.73, 'language': '', 'encoding': 'Windows-1252'} {'confidence': 0.73, 'language': '', 'encoding': 'ISO-8859-1'}

本应该有的结果不是:前是 UTF-8 后面得到的应该为GBK才对啊! 求解

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/2222
 
1073 次点击  
文章 [ 1 ]  |  最新文章 6 年前