python 创建多层级文件结构
import os
def create_folder_structure(path,dir1,dir2):
for dir1_name in dir1:
current_path=path + "\\" + dir1_name
for dir2_name in dir2:
final_path = current_path + "\\" + dir2_name
os.makedirs(final_path, exist_ok=True)
#目标文件夹路径
dis_dir = r"d:\path"
#第一层的所有文件夹
second_dir = ["dir1","dir2","dir3"]
#第一层所有文件夹下创建文件夹
third_dir = ["dir1","dir2","dir3"]
create_folder_structure(dis_dir,second_dir,third_dir)