X编码 U编码 与 中文 转换


# 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)