python chardet.detect(ustring)语句
请问各位大神,这一句codedetect=chardet.detect(ustring)["encoding"]中的["encoding"]代表的意思,是约定必须这样写的...
请问各位大神,这一句codedetect = chardet.detect(ustring)["encoding"]中的["encoding"]代表的意思,是约定必须这样写的吗?
完整的函数代码如下:
def _smartcode(stream):
"""smart recove stream into UTF-8
"""
ustring = stream
codedetect = chardet.detect(ustring)["encoding"]
print ('codedetect')
try:
print ('ustring')
ustring = unicode(ustring,codedetect)
print ('ustringreturn' "%s %s"%("",ustring.encode('utf8')))
except:
return u"bad unicode encode try!" 展开
完整的函数代码如下:
def _smartcode(stream):
"""smart recove stream into UTF-8
"""
ustring = stream
codedetect = chardet.detect(ustring)["encoding"]
print ('codedetect')
try:
print ('ustring')
ustring = unicode(ustring,codedetect)
print ('ustringreturn' "%s %s"%("",ustring.encode('utf8')))
except:
return u"bad unicode encode try!" 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询