import os def traverse(path): subees=os.walk(path) for path, dirs, files in subees: for file in files: print(file) if __name__ == "__main__": traverse("D:/test")