码迷,mamicode.com
首页 > 编程语言 > 详细

python将dict中的unicode打印成中文

时间:2017-08-10 10:27:04      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:jin   tail   cer   number   pytho   log   post   detail   code   

python将dict中的unicode打印成中文

import json

a = {u‘content‘: {u‘address_detail‘: {u‘province‘: u‘\u5409\u6797\u7701‘, u‘city‘: u‘\u957f\u6625\u5e02‘, u‘street_number‘: u‘‘, u‘district‘: u‘‘, u‘street‘: u‘‘, u‘city_code‘: 53}, u‘point‘: {u‘y‘: u‘43.89833761‘, u‘x‘: u‘125.31364243‘}, u‘address‘: u‘\u5409\u6797\u7701\u957f\u6625\u5e02‘}, u‘status‘: 0, u‘address‘: u‘CN|\u5409\u6797|\u957f\u6625|None|CERNET|0|0‘}


print json.dumps(a).decode(‘unicode-escape‘)


输出:
{"content": {"address_detail": {"province": "吉林省", "city": "长春市", "street_number": "", "district": "", "street": "", "city_code": 53}, "address": "吉林省长春市", "point": {"y": "43.89833761", "x": "125.31364243"}}, "status": 0, "address": "CN|吉林|长春|None|CERNET|0|0"}

python将dict中的unicode打印成中文

标签:jin   tail   cer   number   pytho   log   post   detail   code   

原文地址:http://www.cnblogs.com/0x03/p/7337113.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!