python3 \x开头的utf8字符串 怎么转成 中文字符串??

#  python3 \x开头的utf8字符串
utf8_str = '\xe4\xb8\xad\xe6\x96\x87'  # 转成 ’中文‘

python3 \x开头的utf8字符串 怎么转换成 中文字符串??
这个是 ’中文‘,研究了半天不知道怎么转换,谢谢大家了看看怎么转呢……
不是utf8二进制 b'\xe4\xb8\xad\xe6\x96\x87' 转 中文字符串,这个我会……



from urllib import parse

utf8_str = '\xe4\xb8\xad\xe6\x96\x87'  # 转成 ’中文‘
print(utf8_str)         # 直接打印乱码
code1 = utf8_str.encode( 'unicode_ escape ' )           # 编码
code2 = code1.decode('utf-8' ).replace('\\lx', '%' )    # 解码
print(type(code2))  # 查看类型
print(code2)        # 打印结果


https://blog.csdn.net/yungguo/article/details/110197818