存储数据

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)

 

posted @ 2021-01-30 18:17  jerrygogo  阅读(97)  评论(0编辑  收藏  举报