当前位置:首页 > Web开发 > 正文

修改json文件

2024-03-31 Web开发

import os,json f = D:\\temp\\userlist.json f2 = D:\\temp\\userlist2.json file = open(f,rb) fj = json.load(file) file.close() fj[liu].remove(liu.ad3) fj[liu].append(liu.ad4) # print(fj[‘liuchao6‘]) fname = wangwu fj[fname]=[eae] # dict_new = {‘zhangsan‘:[‘abc‘]} # fj.update(dict_new) jsonfile = json.dumps(fj) print(jsonfile) # print(jsonfile) with open(f2,w) as fw: fw.write(jsonfile)

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/40771.html