'''用json包,一行一行写入'''
list = {}
with open("result.json", "w") as f:
list['image_id']='1.jpg'
list['disease_class']=int(str)
json.dump(new_dict, f)
f.close()
dumps: 把python对象转换成json字符串
dump: 对文件的操作
loads: 将已编码的 JSON 字符串解码为 Python 对象
load: 对文件的操作
来源:CSDN
作者:tony2278
链接:https://blog.csdn.net/tony2278/article/details/82987086