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)

  

posted on 2018-12-27 21:55  =.===  阅读(152)  评论(0编辑  收藏  举报

导航