原文链接: https://wuzhuti.cn/python-decodeerror-ascii-codec-cant-decode
import sys
reload(sys)
sys.setdefaultencoding('utf8')
混淆了 python2 里边的 str 和 unicode 数据类型。
1、你需要的是让编码用实际编码而不是 ascii
2、对需要 str->unicode 的代码,可以在前边写上以上代码,把 str 编码由 ascii 改为 utf8 (或 gb18030)、
3、python3 区分了 unicode str 和 byte arrary,并且默认编码不再是 ascii
The post 解决UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe5 in position 108: ordinal not in range(128) appeared first on 无主题博客.
本文转自: https://wuzhuti.cn/python-decodeerror-ascii-codec-cant-decode
本站仅做收录,版权归原作者所有。