序列化:得到一个字符串的结果过程就叫做序列化
import json
dic={‘k1‘:‘v2‘,‘k2‘:‘v2‘}
ret=json.dumps(dic)
print(ret,type(ret))
dic1=json.loads(ret)
print(dic1,type(dic1))
with open("json.txt","w") as f:
json.dump(dic,f)
with open(‘json.txt‘,‘r‘)as f1:
c=json.load(f1)
print(c)
原文:https://www.cnblogs.com/wszxdzd/p/9445447.html