mkdir -p functionality in Python

一句话:使用os.makedirs(path)

import errno    
import os


def mkdir_p(path):
    try:
        os.makedirs(path)
    except OSError as exc:  # Python >2.5
        if exc.errno == errno.EEXIST and os.path.isdir(path):
            pass
        else:
            raise

https://stackoverflow.com/questions/600268/mkdir-p-functionality-in-python

相关文章
添加新评论
取消评论
*
*
*
勇士!消灭0条评论,这么艰巨的任务就靠你了!