test = {“name”: “扎克伯格”, “age”:18}
print test
test_json = json.dumps(test, ensure_ascii=False) ——中文打印会默认为ASCII,所以显示Unicode,需要将ensure_ascii=False才会显示中文
print test_json
test1 = json.loads(test_json)
print test1
运行的结果是:
{‘age‘: 18, ‘name‘: ‘\xe6\x89\x8e\xe5\x85\x8b\xe4\xbc\xaf\xe6\xa0\xbc‘}
{“age”: 18, “name”: “扎克伯格”}
{u‘age‘: 18, u‘name‘: u‘\u624e\u514b\u4f2f\u683c‘}
http://www.mamicode.com/info-detail-2713148.html