阅读背景:

读取指定文档,文档中每一行为一个目录,递归创建所有目录

来源:互联网 
# coding=utf-8
# @author:Damon Qu
# @contact:[email protected]
# @date:2018/4/28
import os
'''
读取指定文档,文档中每一行为一个目录,递归创建所有目录
'''


def create_dirs(path):
    
    # 判断目录是否存在
    isExists = os.path.exists(path)

    if isExists:
        print('%s is exists' % path)
    else:
        os.makedirs(path)
        print('%s create ok' % path)


print("读取指定文档,文档中每一行为一个目录,递归创建所有目录")
file = input("enter the file path:")
with open(file) as f:
    while True:
        line = f.readline().strip()
        if len(line) == 0:
            break
        else:
            create_dirs(line)

# coding=utf-8
# @author:Damon Qu
# @contact:qu



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: