我想创建文件夹使用os.mkdir与循环列表例如我想要12个月份,1月,2月...等名称的文件夹。Python操作系统mkdir(创建与循环列表的文件夹)
import os
months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
for month in months:
os.mkdir('D:\\Python_GIS')
与多行这样我可以创建文件夹我想
import os
os.mkdir('D:\\Python_GIS\\Jan')
os.mkdir('D:\\Python_GIS\\Feb')
os.mkdir('D:\\Python_GIS\\Mar')
os.mkdir('D:\\Python_GIS\\Apr')
os.mkdir('D:\\Python_GIS\\May')
os.mkdir('D:\\Python_GIS\\Jun')
os.mkdir('D:\\Python_GIS\\July')
os.mkdir('D:\\Python_GIS\\Aug')
os.mkdir('D:\\Python_GIS\\Sep')
os.mkdir('D:\\Python_GIS\\Oct')
os.mkdir('D:\\Python_GIS\\Nov')
os.mkdir('D:\\Python_GIS\\Dec')
但有什么办法用循环做到这一点。
感谢
谢谢。这是完美的。 – MKJ 2014-10-27 16:26:58
@shakasom,太棒了,很高兴我能帮到你。一定要纪念这是公认的答案(下投票绿色检查),以便其他用户知道这个答案解决您的问题 – wnnmaw 2014-10-27 16:28:06