UnicodeDecodeError: 'gbk' codec can't decode byte 0xff in position 0: illegal mu

论坛 期权论坛 编程之家     
选择匿名的用户   2021-6-2 20:30   2741   0

混淆了 python2 里边的 str 和 unicode 数据类型。

1.
对需要 str->unicode 的代码,可以在前边写上
import sys
reload(sys)
sys.setdefaultencoding('utf8')
把 str 编码由 ascii 改为 utf8 (或 gb18030)

2.
python3 区分了 unicode str 和 byte arrary,并且默认编码不再是 ascii

转载于:https://www.cnblogs.com/bigbigtree/p/3232545.html

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP