方法一:格式化
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)
网友评论