利用OS自動創建和系統時間名字一樣的文件夾
例子:
結果:創建一個文件夾2018_04_16_19_39_50,裏邊有三個文件夾FP/FN/TP
#!/usr/bin/python
# coding:utf-8
'''
# creat Folder same as system time
# Copyright 2018.4.16 Pulse Analyze Project
# Author: super
# All Rights Reserved.
'''
import os
import time
import datetime
import dateutil.tz
now = datetime.datetime.now(dateutil.tz.tzlocal())
timestampfp = now.strftime('%Y_%m_%d_%H_%M_%S')
dir_FP = '../plot/%s/FP' % \
( timestampfp)
if not os.path.exists(dir_FP):
os.makedirs(dir_FP)
now = datetime.datetime.now(dateutil.tz.tzlocal())
timestampfn = now.strftime('%Y_%m_%d_%H_%M_%S')
dir_FN = '../plot/%s/FN' % \
(timestampfn)
if not os.path.exists(dir_FN):
os.makedirs(dir_FN)
now = datetime.datetime.now(dateutil.tz.tzlocal())
timestamptp = now.strftime('%Y_%m_%d_%H_%M_%S')
dir_TP = '../plot/%s/TP' % \
(timestamptp)
if not os.path.exists(dir_TP):
os.makedirs(dir_TP)