<p>可以使用pprint。这是quora的答案
回答你的问题。在空闲状态下运行它以正确查看未编码字符串</p>
<p><a href="https://www.quora.com/How-do-you-print-a-python-unicode-data-structure" rel="nofollow noreferrer">https://www.quora.com/How-do-you-print-a-python-unicode-data-structure</a></p>
<pre><code>import pprint
_escape = dict((q, dict((c, unicode(repr(chr(c)))[1:-1])
for c in range(32) + [ord('\\')] +
range(128, 161),
**{ord(q): u'\\' + q}))
for q in ["'", '"'])
class MyPrettyPrinter(pprint.PrettyPrinter):
def format(self, object, context, maxlevels, level):
if type(object) is unicode:
q = "'" if "'" not in object or '"' in object \
else '"'
return ("u" + q + object.translate(_escape[q]) +
q, True, False)
return pprint.PrettyPrinter.format(
self, object, context, maxlevels, level)
pp = MyPrettyPrinter()
s = u'\u7279\u6717\u666e\u5973\u513f\u4f0a\u4e07\u5361\u5230\u4e2d\u56fd\u5927\u4f7f\u9986\u8d3a\u65b0\u5e74'
print(s)
data = {
u'title' : s
}
pp.pprint(data)
</code></pre>