import os
def get_all_deep_files_in_folder(folder_path):
all_files = []
file_paths = os.listdir(folder_path)
for item in file_paths:
fp = os.path.join(folder_path,item)
if os.path.isfile(fp):
all_files.append(fp)
else:
all_files = all_files + get_all_deep_files_in_folder(fp)
return all_files
all_files = get_all_deep_files_in_folder(folder_path)
采用递归调用的实现方式,使用时自己指定folder_path即可
标签:files,文件,Python,子目录,deep,fp,path,folder,os From: https://www.cnblogs.com/fzucsx/p/17835535.html欢迎在评论区给出更好方法