os.walk without digging into directories below

前端 未结 20 1312
庸人自扰
庸人自扰 2020-12-04 06:21

How do I limit os.walk to only return files in the directory I provide it?

def _dir_list(self, dir_name, whitelist):
    outputList = []
    for         


        
20条回答
  •  孤城傲影
    2020-12-04 07:18

    The suggestion to use listdir is a good one. The direct answer to your question in Python 2 is root, dirs, files = os.walk(dir_name).next().

    The equivalent Python 3 syntax is root, dirs, files = next(os.walk(dir_name))

提交回复
热议问题