python dict 中的中文处理
dict1 = {'中':'国 '}
print dict1 ##{'\xc3\xa4\xc2\xb8\xc2\xad': '\xc3\xa5\xc2\x9b\xc2\xbd'}
import json
json1 = json.dumps(dict1)
print json1 ##{"\u00e4\u00b8\u00ad": "\u00e5\u009b\u00bd"}
print json1.decode('raw_unicode_escape') ##{"中": "国"}
s = '{"中": "国"}'
dict2 = json.loads(s)
json2 = json.dumps(dict2)
print json2.decode('raw_unicode_escape') ##{"中": "国"}
浙公网安备 33010602011771号