Please help explain this code in Python

This question already has an answer here:

  • How do I list all files of a directory? 31 answers

  • 我会给它一个镜头,希望这有助于。

    import os 
    #   vvvvvvv directory name of the current position in the walk (eg, /var then /var/log then /var/log/apache2, etc)
    #            vvvvvvvv list (array) of sub directories
    #                      vvvvvvvvv list (array) of files
    for dirname, dirnames, filenames in os.walk('# I will have a directory here'): # loops through the directories list
        for filename in filenames: #loops through the files returned by the previous for loop
          print (os.path.join(dirname, filename)) # join the directory and the filename returning something like /var/log/dmesg.log
    
    链接地址: http://www.djcxy.com/p/20048.html

    上一篇: 我如何使用Linux终端命令如CD和LS?

    下一篇: 请帮助在Python中解释这段代码