python 编码转String

类似 \xe9\x9d\x9e\xe6\xb3\x95\xe5\x8f\x82\xe6\x95\xb0 类型的编码

需要先转成byte,再使用decode()方法转换成string(默认是utf-8)

b =  b'\xe9\x9d\x9e\xe6\xb3\x95\xe5\x8f\x82\xe6\x95\xb0'
b.decode()

输出结果

Out[33]: '非法参数'

  

posted @ 2021-10-15 10:47  IVWT  阅读(452)  评论(0)    收藏  举报