python保存时间戳文件

import time
# ISOTIMEFORMAT='%Y-%m-%d %X'
ISOTIMEFORMAT='%Y-%m-%d'
t= time.strftime( ISOTIMEFORMAT, time.gmtime( time.time() ) )
f = open( t + "test.txt",'wb')
f.write("hello,\n This is a test file")
f.close()

计算程序运行时间

import time
# ISOTIMEFORMAT='%Y-%m-%d %X'
start = time.time()
ISOTIMEFORMAT='%Y-%m-%d'
t= time.strftime( ISOTIMEFORMAT, time.gmtime( time.time() ) )
f = open( t + "test.txt",'wb')
f.write("hello,\n This is a test file")
f.close()
print t
elapsed = time.time() - start
print elapsed

out:

2016-05-31
0.00300002098083
05-11 13:03