import json
# dumps #一般处理字符串
# dump #一般处理文件
#字符串和json之间的转换
test_dict={"name":"fxh","age":23}
a=json.dumps(test_dict)
print(a,type(a))
b='{"name": "fxh", "age": 23}'
c=json.loads(b)
print(c,type(c))
#文件和json之间的转换
test_dict={"name":"fxh","age":24}
with open("j.txt","w+") as fd:
json.dump(test_dict,fd)
with open("j.txt","r+") as f:
m=json.load(f)
print(m)