1
reorx 2012-11-05 13:40:16 +08:00
这是个坑爹的问题,在使用 dump 或 dumps 函数的时候一定要传上 ensure_ascii=False 的参数。解释见文档:
If ensure_ascii is True (the default), all non-ASCII characters in the output are escaped with \uXXXX sequences, and the result is a str instance consisting of ASCII characters only. If ensure_ascii is False, some chunks written to fp may be unicode instances. This usually happens because the input contains unicode strings or the encoding parameter is used. Unless fp.write() explicitly understands unicode (as in codecs.getwriter()) this is likely to cause an error. http://docs.python.org/2/library/json.html#json.dump |
2
zhy0216 2012-11-05 13:47:06 +08:00
用Google插件Advanced Rest Client做测试, 会显示中文
|
3
timchou OP |