import os,sys,shutil
def search(rootdir,search_dir_name):
if os.path.isdir(rootdir):
list_new = os.listdir(rootdir)
for it in list_new:
if it == search_dir_name:
#os.rmdir(os.path.join(rootdir,it)) #不能删除有文件的文件夹
shutil.rmtree(os.path.join(rootdir,it))
else:
search(os.path.join(rootdir,it),search_dir_name)
else:
return
search("E:\\code\\trunc\\src\\video\\","Debug")
search("E:\\code\\trunc\\src\\video\\","Release")
python 查找指定名称的目录并删除
最新推荐文章于 2024-09-24 00:23:58 发布