import them def search(a,b): for file in os.listdir(a): #Determine
whether it is a file if os.path.isfile(os.path.join(a,file)): if b in file:
#Split the full path print(file,'=>',os.path.join(a,file).split('\\',1)[1]) else:
#Iteratively process subdirectories search(os.path.join(a,file),b) if __name__ == '__main__': #Get
the directory where the current file is located, and the file that needs to be searched search(os.path.dirname(__file__),'testinit')
The above code can be extended according to the extension to make a tool to quickly search local files. Interested children's shoes can extend together.