list如何不通过循环就打印出中文

脚本如下:

#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
@author:
@contact:
@time:
"""
list = {'channel_id': -3, 'name': u'\u4f60\u597d\uff0c\u8fd9\u4e2a\u4e0d\u5b8c\u7f8e\u7684\u4e16\u754c'}
print(u'\u4f60\u597d\uff0c\u8fd9\u4e2a\u4e0d\u5b8c\u7f8e\u7684\u4e16\u754c')
print(type(u'\u7ea2\u5fc3\u5146\u8d6b'))
print(list)
print (str(list).decode("unicode-escape"))
print(type(str(list).decode("unicode-escape")))

结果:

你好,这个不完美的世界
<type 'unicode'>
{'channel_id': -3, 'name': u'\u4f60\u597d\uff0c\u8fd9\u4e2a\u4e0d\u5b8c\u7f8e\u7684\u4e16\u754c'}
{'channel_id': -3, 'name': u'你好,这个不完美的世界'}
<type 'unicode'>

猜你喜欢

转载自blog.csdn.net/leitouguan8655/article/details/82773012