---
title: "python dict中将unicode打印显示为中文"
author: "sls0919"
date: "2017-10-26T10:25:17Z"
tags: []
categories: ["移动开发"]
slug: "python-dict-unicode"
draft: false
lastmod: "2017-10-26T10:25:17Z"
id: 2397668
url: "https://sls0919.iteye.com/blog/2397668"
---

# [](http://www.cnblogs.com/zejin2008/p/6861800.html)

 

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