python3 中的中文编码问题

在爬网页的时候遇到这种json返回的数据其中包含的中文为一串编码,可以先将其编码为utf-8类型,再将其解码为unicode类型便可正常显示中文.{“data”:null,”info”:”\u7528\u6237\u5df2\u767b\u5f55”,”status”:0}

z=requests.post(post_addr,data=post_data,headers=post_header)
s=z.text.encode('utf-8')#z.text为str类型
print(s.decode('unicode-escape'))

这里写图片描述

猜你喜欢

转载自blog.csdn.net/shenhuaifeng/article/details/78334958