为什么Python的json.dump保存的是unicode?

import json
d={"name":"孙悟空","age":18,"gender":"MALE"}
f=open("d:/test.json","w",encoding='utf-8')
json.dump(d,f)
f.close()

为什么写入的文件中不是汉字,而是unicode?
{"name": "u5b59u609fu7a7a", "age": 18, "gender": "MALE"}

https://img3.mukewang.com/5c5111b10001a99c06630151.jpg

有只小跳蛙
浏览 1033回答 1
1回答

拉丁的传说

json.dump(d,f,ensure_ascii=False)If ensure_ascii is true (the default), the output is guaranteed to have all incoming non-ASCII characters escaped. If ensure_ascii is false, these characters will be output as-is.
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python