现在我试着每天用python自动化创建新的目录文件夹,我需要根据我的列表创建新的Fix子文件夹。如下所示:

这是我的脚本:
import os
from datetime import date
today = date.today()
d1 = today.strftime("%d-%m-%Y")
#Ie Source Path
ie = ["G:/01-FIN & ACC-Confidential/Inbound/IE-Direct/",
"G:/02-BDSM (ห้ามย้ายเด็ดขาด)-Confidential/Inbound/IE-Direct/",
"G:/03-BSC-Confidential/Inbound/IE-Direct/",
"G:/04-CLD-Confidential/Inbound/IE-Direct/",
"G:/05-COMPLIANCE-Confidential/Inbound/IE-Direct/",
"G:/06-CRD-Confidential/Inbound/IE-Direct/",
# define the access rights
access_rights = 0o755
team = ["ACCOUNTING","BDSM","BSC","CLD","COMPLIANCE","CRD","HR","IT","MGT","MKT","OPS","COPORATE SALES","TELESALES","PASSAPORN","FRAUD","LEGAL","INS","BIQM",]
for i,j in ie+team:
os.mkdir(i+str(d1)+"/"+j)请告诉我如何在已经用当前程序创建的文件夹中创建子目录。
发布于 2020-05-28 18:00:50
我试过你的代码,但它显示的值太多,无法解压,然后我修改了你的代码,创建了6个目录,然后在这6个目录中再次创建了3个子目录。
from datetime import date
today = date.today()
d1 = today.strftime("%d-%m-%Y")
#Ie Source Path
ie = ["D:/t/",
"D:/t/",
"D:/t/",
"D:/t/",
"D:/t/",
"D:/t/"]
# define the access rights
access_rights = "0o755"
team = ["ACCOUNTING","BM","BSC","CLD","COMPLIANCE","CRD"]//actual 6 directories
new_subs=["1","2","3"] //names of 3 subdirectories
os.mkdir(ie[0]+str(d1))//main directory named as today's date
for i in range(0,6):
os.mkdir(ie[i]+str(d1)+"/"+team[i])
for j in range(len(new_subs)):
os.mkdir(ie[i]+str(d1)+"/"+team[i]+"/"+new_subs[j])如果他们对代码有任何疑问,请给出评论
https://stackoverflow.com/questions/62061311
复制相似问题