#coding=gbk
import os
import time
g_filelist = []
"""
遍历dir,并获取该目录下的所有文件
"""
def getFileList(dir):
global g_filelist
for f in os.listdir(dir):
file = os.path.join(dir, f)
if os.path.isdir(file):
getFileList(file)
elif os.path.isfile(file):
g_filelist.append(file)
if __name__ == '__main__':
print "Start["+time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))+"]"
getFileList("E:\\work\\code\\MyCLib")
for filename in g_filelist:
print filename
print "End["+time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))+"]"
遍历目录并将目录下所有文件放到列表中-Python
最新推荐文章于 2023-01-20 15:19:21 发布