python读取多层嵌套文件夹中的文件
由于工作安排,需要读取多层文件夹下嵌套的文件,文件夹的结构如下图所示:

想到了递归函数,使用python的os.path.isfile方法判断当前是不是可执行文件,如果不是再用os.listdir方法将子目录循环判断。
代码如下
import os
path = 'abc'
path_read = [] #path_read saves all executable files
def check_if_dir(file_path):
temp_list = os.listdir(file_path) #put file name from file_path in temp_list
for temp_list_each in temp_list:
if os.path


1411

被折叠的 条评论
为什么被折叠?



