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