# -*- coding: utf-8 -*-
# @Time : 2018/12/23 8:09
# @Author : Philly
# @File : make_directories.py
# @Description: 批量创建文件夹
import os
path = r‘C:\Users\hasee\Desktop\resources\学习\LearningNotes\MySQL\books\mysql_scripts\\‘
for i in range(2, 31):
file_name = ‘chapter‘ + str(i)
dir_name = path + file_name
if file_name not in os.listdir(path): # 文件夹名称不存在才创建
os.mkdir(dir_name)
# print(‘chapter1‘ in os.listdir(path))
原文:https://www.cnblogs.com/liuliu3/p/10163266.html