纯记录,详情请参考
https://www.cnblogs.com/xiaoxiaoweng/p/10966220.html
1. 想要以时间来建文件夹
2. 解决办法
time_str = datetime.datetime.now().strftime('%m%d-%H-%M')
tensorboard_path = "../output/{}/tensorboard/".format(time_str)
if not os.path.exists(tensorboard_path):
os.makedirs(tensorboard_path)
makedirs可以把中间的路径不存在的文件夹也新建出来
(1)字符串转datetime:
>>> string = '2014-01-08 11:59:58'
>>> time1 = datetime.datetime.strptime(string,'%Y-%m-%d %H:%M:%S')
>>> print time1
2014-01-08 11:59:58
(2)datetime转字符串:
>>> time1_str = datetime.datetime.strftime(time1,'%Y-%m-%d %H:%M:%S')
>>> time1_str
'2014-01-08 11:59:58'