ficapy
9/8/2015 - 11:46 AM

JSON输出中文

JSON输出中文

# http://stackoverflow.com/questions/18337407/saving-utf-8-texts-in-json-dumps-as-utf8-not-as-u-escape-sequence
print(json.dumps({u'卧槽': u'卧槽'}, indent=4).decode('unicode-escape').encode('utf8'))

print(json.dumps({u'卧槽': u'卧槽'}, indent=4, ensure_ascii=False))