我在包含非ASCII字符的字符串中包含ASCII字符。当我尝试对其进行解码时,我得到一个奇怪的框字符。如何正确解码这些字符?
string = 'So you\u0019ve got an elevator pitch(/nivi/2009/04/how-to-write-an-elevator-pitch.html) \u0014 a short, pithy description of why your business is special, exciting, and unique.'.encode()
print(string)
decode = string.decode('unicode_escape')
print("Decoded: ", decode)
输出:
b'So you\x19ve got an elevator pitch(/nivi/2009/04/how-to-write-an-elevator-pitch.html) \x14 a short, pithy description of why your business is special, exciting, and unique.'
Decoded: So youve got an elevator pitch(/nivi/2009/04/how-to-write-an-elevator-pitch.html) a short, pithy description of why your business is special, exciting, and unique.