# X 编码 b="\xE6\x88\x91\xE6\x98\xAF\xE8\xAF\xB7\xE6\xB1\x82" # U编码 c='\u4eca\u65e5\u5df2\u7ecf\u5b8c\u6210\u8fc7\u6b64\u4efb\u52a1\uff0c' print(b) print(c) #Python X 编码转中文 bb = (b.encode('raw_unicode_escape')).decode() #Python U 编码转中文 cc = c.encode('utf-8').decode("utf8") print (bb) print(cc) # X 编码 b = bb.encode().decode('raw_unicode_escape') # U编码 c = cc.encode().decode('utf-8') print(b) print(c)
1 s = b'\u897f' 2 print(s) 3 print(s.decode('unicode-escape')) 4 5 list = [b'\u897f'] 6 s = b"".join(list) 7 print(s) 8 s = s.decode('unicode-escape') 9 print(s) 10 print(s.split(',')) 11 12 输出: 13 b'\\u897f' 14 西 15 b'\\u897f' 16 西 17 ['西']