我正在使用Python 3,但在将格式从字符串转换为字节时,在服务器日志中发现了此错误
b'\x00\x01_\x97'.decode()
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
b'\x00\x01_\x97'.decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x97 in position 3: invalid start byte
如何将字符串转换为字节值?我
发布于 2018-05-20 20:04:05
您需要通过以下方式指定编码类型Latin
>>> b'\x00\x01_\x97'.decode("Latin")
'\x00\x01_\x97'
>>> type(b'\x00\x01_\x97'.decode("Latin"))
<class 'str'>
>>>
https://stackoverflow.com/questions/50432533
复制相似问题