os.walk 沒有深入到下面的目錄

| | | | | | | | | | | |

如何限制 os.walk 只返回我提供的目錄中的文件?

def _dir_list(self, dir_name, whitelist): outputList = [] for root, dirs, files in os.walk(dir_name): for f in files: if os.path.splitext(f)[1] in whitelist: outputList.append(os.path.join(root, f) ) else: self._email_to_("ignore") return outputList