本文实例分析了python删除指定类型(或非指定)的文件用法。分享给大家供大家参考。具体如下: 如下,删除目录下非源码文件 import os import string def del_files(dir,topdown=True): for root, dirs, files in os.walk(dir, topdown): for name in files: pathname = os.path.splitext(os.path.join(root, name)) if (pathname[1] != ".cpp" and pathname[1