修正数据到json格式
def test(): file_path = r'./data/0914/position_predict_100.txt' save_path = r'./data/0914/position_predict_100.json' save_dict = {} with open(file_path, 'r', encoding='utf8') as fr: with open(save_path, 'w', encoding='utf8') as fw: content = fr.readlines() for each in content: each_dict = dict(eval(each.strip())) save_dict[each_dict["_id"]] = each_dict json.dump(save_dict, fw, indent=4) print('ok')
时刻记着自己要成为什么样的人!