遍历目录下所有文件
#!/usr/bin/env python
#####################
#os.getcwd()
#os.mkdir()
#os.listdir()
#os.stat()
#os.rmdir()
#os.walk()
#####################
import os
path="/opt/python"
def enumeratepaths(path=path):
fullpath=[]
for paths,dirs,files in os.walk(path):
for file in files:
filepath=os.path.join(paths,file)
fullpath.append(filepath)
return fullpath
print enumeratepaths(path=path)
阅读(1342) | 评论(0) | 转发(0) |