Python os.walk 停止遍历满足条件的文件夹

Python os.walk 停止遍历满足条件的文件夹

import os

for here, dirs, files in os.walk(startdir, topdown=True):
    dirs[:] = []    

注意:dirs[:] = [] 不能改为 dirs = []

posted @ 2021-12-31 17:56  ibingshan  阅读(223)  评论(0编辑  收藏  举报