python json (loads(),load(),jump(),jumps())

# loads() str to json data
# jumps() json to str
# jump() json to file
def ladstest():
data = '{"name": "July", "salary": 999999, "title": "CEO", "manager": null}'
json_data=json.loads(data)
print(json_data)

s = json.dumps(json_data)
print(s)
json.dump(json_data,open("C:\python\demo\LiaoXueFeng\data\testjs2.json","w"))

#load() file to json
def ladtest():
f =open("C:\python\demo\LiaoXueFeng\data\testjs.json","r")
json_data = json.load(f)
f.close()
print(json_data)


ladstest()
posted @ 2017-08-15 14:15  大树2  阅读(1227)  评论(0编辑  收藏  举报