1、json.dump()储存数据。
import json nums=[1,2,3,4,5] filename="numbers.json" with open(filename,"r+") as f: json.dump(nums,f)
2、json.load()读写数据。
import json filename="numbers.json" with open(filename,"r+") as f: r=json.load(f) print(r)
原文:https://www.cnblogs.com/yijierui/p/14349937.html