def searchFile(key = '', p = '.', L = None):
if L is None:
L = []
path = p
for x in os.listdir(path):
filePath = path + sep + x
if os.path.isdir(filePath):
searchFile(key, filePath, L)
if os.path.isfile(filePath) and os.path.split(filePath)[1].find(key) > -1:
L.append(os.path.abspath(filePath))
return L
UTOO_NAIVE
import os
sep = os.path.sep
def searchFile(key = '', p = '.', L = None): if L is None: L = [] path = p for x in os.listdir(path): filePath = path + sep + x if os.path.isdir(filePath): searchFile(key, filePath, L) if os.path.isfile(filePath) and os.path.split(filePath)[1].find(key) > -1: L.append(os.path.abspath(filePath)) return L
for s in searchFile('py'): print(s)