Python_创建时间目录的封装2(os.path&localtime)

创建时间目录的封装2(os.path&localtime)

import os
import os.path
from Util.GetTime import *
def make_date_dir(dir_path):
    if os.path.exists(dir_path):
        path = os.path.join(dir_path,get_current_date())
        if not os.path.exists(path):
            os.mkdir(path)

def make_time_dir(dir_path):
    if os.path.exists(dir_path):
        path = os.path.join(dir_path,get_current_time())
        if not os.path.exists(path):
            os.mkdir(path)
        else:
            raise Exception("dir path does not exist!")

if __name__ == "__main__":
    try:
        make_time_dir("e:\\testman2227777777")
    except:
        print("创建目录失败")
posted @ 2019-12-29 19:09  翻滚的小强  阅读(126)  评论(0)    收藏  举报