删除某个文件夹下所有指定文件
程序员文章站
2022-05-20 10:20:37
...
import os
path = "./experiment_normal" ## modify the path according to your own need
del_file=['training_args.bin','config.json', 'pytorch_model.bin', 'special_tokens_map.json', 'tokenizer_config.json', 'vocab.txt'] ## modify it
for dir_path,dir_name,file_name in os.walk(path):
for file in file_name:
if file in del_file:
os.remove(os.path.join(dir_path,file))
服务器被憨憨搞炸了,一晚上结果白跑,把模型文件都删掉呗