【发布时间】:2019-07-20 05:11:41
【问题描述】:
我有一个字符串,其中包含编码字节:
str1 = "b'Output file \xeb\xac\xb8\xed\x95\xad\xeb\xb6\x84\xec\x84\x9d.xlsx Created'"
我想解码它,但我不能,因为它已经变成了一个字符串。因此我想问是否有任何方法可以将其转换为
str2 = b'Output file \xeb\xac\xb8\xed\x95\xad\xeb\xb6\x84\xec\x84\x9d.xlsx Created'
这里的str2 是一个bytes 对象,我可以使用它轻松解码
str2.decode('utf-8')
得到最终结果:
'Output file 문항분석.xlsx Created'
【问题讨论】:
标签: python python-3.x decode