hex_byte = b'\xe7\x8e\xa9\xe5\xae\xb6\x33\x38\x35'
result_byte = hex_byte.decode('utf-8')
print(f'1.bytes类型的十六进制经过utf-8解码之后的数据为:{result_byte}')
import codecs
hex_chinese = 'e4b8ade59bbde4babae4b88de9aa97e4b8ade59bbde4baba'
# 将十六进制的字符串数据进行解码
result_str = codecs.decode(hex_chinese.encode('utf-8'), "hex").decode('utf-8')
print(f'2.十六进制的字符串经过解码最终的结果为:{result_str}')
chinese = '中国人不骗中国人'
# 字符串生成十六进制
hex_chinese = chinese.encode('utf-8')
print(f'==>中文转成十六进制的结果为:{hex_chinese}')
hex_chinese = hex_chinese.hex()
print(f'==>中文转成十六进制的结果为:{hex_chinese}')
附加
进制在线转换工具网站:https://www.bejson.com/convert/ox2str/