删除某个文件夹下所有指定文件

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))

服务器被憨憨搞炸了,一晚上结果白跑,把模型文件都删掉呗

猜你喜欢

转载自blog.csdn.net/weixin_43301333/article/details/112461487
今日推荐