python格式化保存list到json文件

    科技2022-08-13  97

    1. 代码 

    json_file_path = '/home/zxq/PycharmProjects/data/ciga_call/result.json' json_file = open(json_file_path, mode='w') save_json_content = [] for img_name in img_name_list: result_json = { "image_name": img_name, "category": 1, "score": 0.99074} save_json_content.append(result_json) json.dump(save_json_content, json_file, indent=4) # json.dump(save_json_content, json_file, ensure_ascii=False, indent=4) # 保存中文

    2. 保存的json文件: 

    Processed: 0.018, SQL: 8