这是一个制作格式化时间戳的范例
import time
ctime = time.ctime()
time_cur = time.time()
time_cur_loc = time.localtime()
mdr_timestamp = '%04d%02d%02d_%02d%02d%02d' % (\
time_cur_loc.tm_year,\
time_cur_loc.tm_mon,\
time_cur_loc.tm_mday,\
time_cur_loc.tm_hour,\
time_cur_loc.tm_min,\
time_cur_loc.tm_sec\
)
print 'ctime = ' + str(ctime)
print 'time_cur = ' + str(time_cur)
print 'time_cur_loc = ' + str(time_cur_loc)
print 'timestamp = ' + str(mdr_timestamp)
输出结果为: