Discuss / Python / .

UTOO_NAIVE

#1 Created at ... [Delete] [Delete and Lock User]

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)


  • 1

Reply