import os
def search(x,dir):
for thing in os.scandir(dir):
newpath=os.path.join(dir,thing.name)
if os.path.isfile(thing):
if x in thing.name:
print(os.path.relpath(newpath,a)) #global
elif os.path.isdir(thing):
search(x,newpath)
a=os.getcwd()
b=input('please input what you want to find:')
search(b,a)
浴火化影
import os def search(x,dir): for thing in os.scandir(dir): newpath=os.path.join(dir,thing.name) if os.path.isfile(thing): if x in thing.name: print(os.path.relpath(newpath,a)) #global elif os.path.isdir(thing): search(x,newpath)
a=os.getcwd() b=input('please input what you want to find:') search(b,a)