【发布时间】:2022-01-23 18:15:39
【问题描述】:
这是我的 json 文件:
{"dates" : ["15-12-2021", "16-12-2021", "17-12-2022"]}
这是我的代码:
with open(path_to_json_file, 'r') as jsonf:
data = json.load(jsonf)
data_ = data['dates']
for date in data_:
imgs_to_delete.append(dates)
#I want to remove here date from the json file
将日期变量保存在列表中后,我想将其从 json 文件中删除。
例如:我只想从 json 文件中删除“16-11-2021”。我该怎么做。
【问题讨论】:
-
您可以尝试编写正则表达式,如link中所示