您的位置:首页 > 编程语言 > Python开发

python列举目录(包括子目录)下的所有文件

2011-12-09 14:47 120 查看
def ListFiles(dir) :
print "list file in dir ", os.path.abspath(dir)
subdir = []
for item in os.listdir(os.path.abspath(dir)) :
if os.path.isfile(os.path.join(dir, item)) :
print item
else :
subdir.append(os.path.join(dir, item))

for sdir in subdir :
ListFiles(sdir)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: