python+selenium+new——格式化日期 ——新建以时间为名字的文件夹

import time
import os


#--------------------------------------------------------------------------------

picture_time = time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime(time.time()))

print(picture_time)                 #  2020-02-15-19-18-38

#--------------------------------------------------------------------------------


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

print(picture_time2)                 #  2020-02-15

#--------------------------------------------------------------------------------


picture_time3 = time.strftime("%H-%M-%S", time.localtime(time.time()))

print(picture_time3)                 #  2020-02-15

#--------------------------------------------------------------------------------

os.mkdir('C:\\Users\\del\\Desktop\\'+picture_time)
os.mkdir('C:\\Users\\del\\Desktop\\'+picture_time2)
os.mkdir('C:\\Users\\del\\Desktop\\'+picture_time3)

 

 

 

执行结果:

 

2020-02-15-19-37-55
2020-02-15
19-37-55

 

 

posted @ 2020-02-15 19:39  小白龙白龙马  阅读(222)  评论(0编辑  收藏  举报