import osdef search(path, filename): dirspool = [] filespool = {} count = 0 for root, dirs, files in os.walk(path, topdown=True): for name in dirs: dir_name = os.path.join(root, name) dirspool.append(dir_name) for name in files: file_name = os.path.join(root, name) count += 1 filespool[count] = file_name target = [x[1] for x in filespool.items() if filename in x[1]] return target
>>> print(search('g:/','ha'))
['g:/cccc\\cccc-b\\haha.txt']
Velskerd