赞
踩
1,os.mkdir()
只能创建一个不存在的目录
2,os.makedirs()
递归地创建多个不存在的目录
import os
pth = r"dir1" # dir1不存在
if not os.path.exists(pth):
os.mkdir(pth)
import os
pth = r"dir2/dir3" # dir2, dir3都不存在
if not os.path.exists(pth):
os.mkidr(pth)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。