创建文件夹

创建文件夹

# 创建文件夹
def mkdir(path):
    # 引入模块
    import os
    # 去除首位空格
    path = path.strip()
    # 去除尾部  符号
    path = path.rstrip("\")
    # 判断路径是否存在
    isExists = os.path.exists(path)
    if not isExists:
        os.makedirs(path)
        print(path + ' 创建成功')
        return True
    else:
        print(path + ' 目录已存在')
        return False

# 定义要创建的目录
mkpath = "D:\雅诗兰黛\tmp\%s" % (sheet_m)
# 调用函数
mkdir(mkpath)
原文地址:https://www.cnblogs.com/yanjiayi098-001/p/13152173.html