python创建日期名的目录

2023-01-31 05:01:56 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

 

相关文章