请帮助在Python中解释这段代码
这个问题在这里已经有了答案:
我会给它一个镜头,希望这有助于。
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/20047.html