How do you walk through the directories using python?

前端 未结 4 1502
长情又很酷
长情又很酷 2020-12-15 17:23

I have a folder called notes, naturally they will be categorized into folders, and within those folders there will also be sub-folders for sub categories. Now my problem is

4条回答
  •  忘掉有多难
    2020-12-15 18:02

    You could do this:

    list_of_files = dict([ (file, os.sep.join((dir, file)))
                           for (dir,dirs,files) in os.walk(path)
                           for file in files
                           if file[-5:] == '.html' ])
    

提交回复
热议问题