python dict中将unicode打印显示为中文
dict内容:
d = {u'status': u'BASE_ERROR', u'code': 7, u'uid': u'b660be2a-3a4d-4c40-bc1d-3c55cf7eb340', u'content': None, u'handler': u'USER', u'busiCode': u'-2', u'version': u'001', u'msg': u'\u67e5\u8be2geohash\u5468\u56f4\u53f8\u673a\u7ecf\u7eac\u5ea6\u4fe1\u606f\u5f02\u5e38com.zuche.redis.TedisConnectionException: java.net.ConnectException: Connection timed out'}
展示中文, 直接上代码:
In [165]: d = {u'status': u'BASE_ERROR', u'code': 7, u'uid': u'b660be2a-3a4d-4c40-bc1d-3c55cf7eb340', u'content': None, u'handler': u'USER', u'b ...: usiCode': u'-2', u'version': u'001', u'msg': u'\u67e5\u8be2geohash\u5468\u56f4\u53f8\u673a\u7ecf\u7eac\u5ea6\u4fe1\u606f\u5f02\u5e38co ...: m.zuche.redis.TedisConnectionException: java.net.ConnectException: Connection timed out'} In [166]: print d {u'status': u'BASE_ERROR', u'content': None, u'code': 7, u'busiCode': u'-2', u'uid': u'b660be2a-3a4d-4c40-bc1d-3c55cf7eb340', u'version': u'001', u'msg': u'\u67e5\u8be2geohash\u5468\u56f4\u53f8\u673a\u7ecf\u7eac\u5ea6\u4fe1\u606f\u5f02\u5e38com.zuche.redis.TedisConnectionException: java.net.ConnectException: Connection timed out', u'handler': u'USER'} In [167]: import json In [168]: dd = json.dumps(d).decode('unicode-escape') In [169]: print dd {"status": "BASE_ERROR", "content": null, "code": 7, "busiCode": "-2", "uid": "b660be2a-3a4d-4c40-bc1d-3c55cf7eb340", "version": "001", "msg": "查询geohash周围司机经纬度信息异常com.zuche.redis.TedisConnectionException: java.net.ConnectException: Connection timed out", "handler": "USER"}
相关推荐
YENCSDN 2020-11-17
lsjweiyi 2020-11-17
houmenghu 2020-11-17
Erick 2020-11-17
HeyShHeyou 2020-11-17
以梦为马不负韶华 2020-10-20
lhtzbj 2020-11-17
夜斗不是神 2020-11-17
pythonjw 2020-11-17
dingwun 2020-11-16
lhxxhl 2020-11-16
坚持是一种品质 2020-11-16
染血白衣 2020-11-16
huavhuahua 2020-11-20
meylovezn 2020-11-20
逍遥友 2020-11-20
weiiron 2020-11-16