json

import json

shopping = {
'name':'zhangwuji',
'age':'1999'

}

# f = open('json1.json','w')
# f.write(json.dumps(shopping))
# f.close()

with open('j.json','w') as f:
json.dump(shopping,f)



-----------------------------------------------


import json
#
# f = open('json1.json','r')
# s = json.loads(f.read())
# f.close()

with open('j.json','r') as f:
s = json.load(f)

print(s)
原文地址:https://www.cnblogs.com/lokerx/p/10930794.html