python获取指定路径下的所有文件
def GetFileList(dir,filelist):
newDir = dir
if os.path.isfile(fir):
filelist.append(dir.decode('gbk'))
elif os.path.isdir(dir):
for s in os.listdir(dir):
if s.endswith(".abs") or s.endswith(".sh") or s.endswith(".py") or s.endswith(".prototxt"
continue
newDir = os.path.join(dir, s)
GetFileList(newDir, filelist)
return filelist
本文介绍了一个Python函数GetFileList,该函数用于获取指定目录下所有文件,并排除特定类型的文件(如.abs, .sh, .py, .prototxt)。通过递归方式遍历目录,将符合条件的文件路径添加到列表中返回。

被折叠的 条评论
为什么被折叠?



