zl程序教程

您现在的位置是:首页 >  其他

当前栏目

使用json读写文件中的数据

文件数据JSONJSON 读写 使用
2023-09-11 14:13:56 时间

把json的数据写入到文件中

import json

with open('data.json','w+') as f:

    json.dump({"name":"张彪"},f)

把json的数据从文件中读取出来

import json

with open('data.json','r') as f:
 
    x=json.load(f)
    print(x,type(x))