s = "图片picture"
print chardet.detect(s)
for c in s.decode(‘utf-8‘):
print c
UnicodeEncodeError: ‘ascii‘ codec can‘t encode character u‘\u5728‘ in position 1
解决方案:
reload(sys)
sys.setdefaultencoding("utf8")
UnicodeEncodeError: 'ascii' codec can't encode character u'\u5728' in position 1
时间: 2024-11-20 08:10:24