递归
循环读取文件信息
# -*- coding:utf-8 -*-
import os
def get_files(path_name):
files = []
if(os.path.exists(path_name)):
for f in os.listdir(path_name):
new_path = path_name + "/" + f
if(os.path.isdir(new_path)):
files += get_files(new_path)
else:
files.append(new_path)
else:
print(f"当前路径{path_name}不存在!")
return []
return files
if __name__ == '__main__':
print(get_files("D:/app"))
今天只有一点点~~~~