请帮助用Python解释此代码

Ath*_*lya -5 python file

import os 

for dirname, dirnames, filenames in os.walk('# I will have a directory here'):
    for filename in filenames:
        print (os.path.join(dirname, filename))
Run Code Online (Sandbox Code Playgroud)

它旨在打印Python中某些文件的目录。但是除了我所知甚少的其他形式...谢谢...还有其他代码页,但是它并没有在“虚拟傻瓜指南”样式中完全解释它。所以我有些困惑。谢谢你的帮助..:)

小智 5

我会试一试,希望这会有所帮助。

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
Run Code Online (Sandbox Code Playgroud)