#!/usr/bin/env python
#coding=utf8
import os.path
import fnmatch
import glob
def recursiveSearchFiles(dirPath, partFileInfo):
fileList = []
pathList = glob.glob(os.path.join('\\', dirPath, '*'))#windows path
#print 'pathList = '
#print pathList
for mPath in pathList:
#print mPath
if fnmatch.fnmatch(mPath, partFileInfo):
fileList.append(mPath) #符合条件条件加到列表
elif os.path.isdir(mPath):
#print mPath
fileList += recursiveSearchFiles(mPath, partFileInfo) #将返回的符合文件列表追加到上层
else:
pass
return fileList
path = recursiveSearchFiles("C:\\Users\\Administrator\\Desktop\\", "*.py")#windows path
print path