Display unicode print as Chinese in python dict

 

 

dict content:

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'}

 

Display Chinese, directly on the code:

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"}

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326094061&siteId=291194637