json in python conversion

json.dumps () to solve garbled error occurred while converting:

json.dumps default for non-ascii characters are generated corresponding to the character code, rather than the original character, for example:

>>> import json
>>> js = json.loads('{"haha": "哈哈"}')
>>> print json.dumps(js)
{"name": "\u54c8\u54c8"}

The solution is simple:

>>> print json.dumps(js, ensure_ascii=False)   
{"name": "哈哈"}  

Guess you like

Origin www.cnblogs.com/fcc-123/p/11351490.html