heychenbin
1/27/2014 - 3:16 AM

Python创建文件夹

Python创建文件夹

import os

def make_dir(dst_dir):
    dir_sep = os.sep

    if dir_sep == dst_dir[-1]:
        dst_dir = dst_dir[:-1]

    if dst_dir and not os.path.isdir(dst_dir):
        head, tail = os.path.split(dst_dir)
        make_dir(head)
        os.mkdir(dst_dir, 0777)