Unicode string,类型为str
Byte string, 类型为bytes
Python3的str 默认不是bytes,所以不能decode,只能先encode转为bytes,再decode
python2的str 默认是bytes,所以能decode
所以str.decode 本质是bytes类型的str的decode
python3经常出现 AttributeError: ‘str’ object has no attribute ‘decode’
非要这样玩,只能先encode转为bytes,再decode
强制转换忽略错误:
bytes.decode(‘’utf-8‘’, ‘’ignore‘’)
————————————————
版权声明:本文为CSDN博主「柠 檬没我萌」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_43192819/article/details/108981008
编码就是encode,把你认识的转为,机器人认识的
解码decode,就是吧一堆机器认识的,解释为人能读懂的