# REPLACEMENTS = {"name":"kai"}#python字典类型对象
# jso = json.dumps(REPLACEMENTS)#将字典对象转化为json对象,其实是字符串
# print(type(jso))#输出str
# dico = json.loads(jso)#将json对象转化为python字典对象
# print(dico)#输出dict
# with open("test.json","w") as f:
# f.write(jso)
#
# with open("test.json","r") as f1:
# print(json.load(f1))
运行结果:
<class ‘str’>
{‘name’: ‘kai’}
{‘name’: ‘kai’}