2024-09-30 18:30:27 发布
网友
在python中解码utf-8编码的字符串变量时遇到了一个问题。在
text = b'JAK SI\xc4\x98 \xe2\x80\x9eNAZYWA\xe2\x80\x9d?' text.decode() -> OK text = str(text) text.decode()
Error:'str' object has no attribute 'decode'
我只能访问字符串变量。如何从字符串变量中解码utf-8编码的文本?谢谢!在
>>> text = b'JAK SI\xc4\x98 \xe2\x80\x9eNAZYWA\xe2\x80\x9d?' >>> text.decode() 'JAK SIĘ „NAZYWA”?' >>> s = str(text) "b'JAK SI\\xc4\\x98 \\xe2\\x80\\x9eNAZYWA\\xe2\\x80\\x9d?'" >>> eval(s).decode() 'JAK SIĘ „NAZYWA”?'
这是你想要的吗?在
这是你想要的吗?在
相关问题 更多 >
编程相关推荐