json模块
import json # dic = {"baby":None, "hxm":False, "syy":"史杨杨"} # # s = json.dumps(dic, ensure_ascii=False) # json处理中文的问题 # print(s) # d = json.loads('{"baby": null, "hxm": false, "syy": "史杨杨"}') # print(d['baby']) f = open("baby.json", mode="w", encoding="utf-8") json.dump({"baby":None, "hxm":False, "syy":"史杨杨"}, f, ensure_ascii=False) # f = open("baby.json", mode="r", encoding="utf-8") # obj = json.load(f) # print(type(obj)) # print(obj)