python创建日期名的目录

  在服务器维护过程中,经常需要创建日期名的目录,以下是python的方法:

 

#!/usr/bin/env python

import os
import time

time=time.strftime("%Y-%m-%d")

backdir = "/data/backup/mysqlbackup/"
mysqlbkdir = backdir + time +"/"
if not os.path.exists(mysqlbkdir):
    os.makedirs(mysqlbkdir)
else:
    pass

 

你可能感兴趣的:(日期名目录)