美文网首页
unicode编码 转 中文

unicode编码 转 中文

作者: 还是那个没头脑 | 来源:发表于2021-05-24 16:47 被阅读0次

方法一:格式化

a = "\u8d44\u8bafnew"
print(u'{}'.format(a))

方法二:先编码再解码

a = "\u8d44\u8bafnew"
print(a.encode('utf-8').decode('utf-8'))

scrapy 爬虫返回json格式内容unicode编码转换为中文的问题解决

def parse(self, response):
     datas = json.dumps(response.text, ensure_ascii= False, indent=4, separators=(',', ': '))
     json_data = json.loads(datas).encode('utf-8').decode('utf-8')
     print(json_data)

相关文章

网友评论

      本文标题:unicode编码 转 中文

      本文链接:https://www.haomeiwen.com/subject/pcgxsltx.html