python中创建多个文件夹
import os
path = r'C:\Users\Administrator\Desktop\学习\9月'
def multi_mkdir(name,start,end):
'''
name:'*{}*',name中必须包含一个{} eg:8.{}
start:1,2.. ,数字就可以了
end:1,2.. ,数字就可以了,大于start
'''
for i in range(start,end+1):
# 如果不存在对应的文件夹,就创建
if not os.path.exists(path + '\\' + name.format(i)):
os.mkdir(path + '\\' + name.format(i))
# for i in range(4,32):
# # 如果不存在对应的文件夹,就创建
# if not os.path.exists(path + '\\'+ '8.{}'.format(i)):
# os.mkdir(path + '\\'+ '8.{}'.format(i))
multi_mkdir('9.{}',1,30)
结果: