Discuss / Python / 作业2

作业2

Topic source

Super-String

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



def find_files(path, search_str):
    for root, dirs, files in os.walk(path):
        for file in files:
            if search_str in file:
                file_path = os.path.join(root, file)
                rel_path = os.path.relpath(file_path, path)
                print(rel_path)



# Example usage
find_files('.', 'test')


  • 1

Reply