python 遍历文件夹 文件

import os
import os.path
rootdir = "/Users/chen/deploy/code/alaudadeploy/deb-linux-4.4.0-21-generic"

for parent,dirnames,filenames in os.walk(rootdir):
for dirname in dirnames:
print "parent is:" + parent
print "dirname is" + dirname

for filename in filenames:
print "parent is:" + parent
print "filename is:" + filename
print "the full name of the file is:" + os.path.join(parent,filename)

原文地址:https://www.cnblogs.com/show668/p/5591454.html