python json模块使用

import json #导入JSON模块

with open('data.json',encoding='utf-8') as json_file: #读取JSON文件
    py_obj=json.load(json_file)  #JSON文件读取到字典



with open('data1.json','w') as json_wfile: #写文件
    json.dump(py_obj,json_wfile) #将字典写入json文件中

  

posted @ 2024-02-18 08:21  小戳同学  阅读(14)  评论(0编辑  收藏  举报