python 笔记
2023-05-04 本文已影响0人
午字横
存储
json.dump:接受两个实参,要储存的数据,以及可用于存储的文件对象
import json
numbers=list(range(100))
filename="my_number.json"
with open(filename,"w") as f:
json.dump(numbers,f)
读取
import json
ilename="my_number.json"
with open(filename,"r")as f:
print(json.load(f))
2023-05-05