os.walk without digging into directories below

前端 未结 20 1315
庸人自扰
庸人自扰 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 06:59

    A slight change to Alex's answer, but using __next__():

    print(next(os.walk('d:/'))[2]) or print(os.walk('d:/').__next__()[2])

    with the [2] being the file in root, dirs, file mentioned in other answers

提交回复
热议问题