显示程序运行时间_python
之前写了IDL中如何显示运行时间,下面来看看你python中如何显示.
1 import datetime 2 import time 3 begintime=time.strftime("%Y-%m-%d %H:%M:%S") 4 print 'Time Begin:'+begintime 5 starttime = datetime.datetime.now() 6 7 print "END" 8 endtime=time.strftime("%Y-%m-%d %H:%M:%S") 9 print 'Time End:'+endtime 10 finishtime=datetime.datetime.now() 11 runtime=(finishtime-starttime).seconds 12 timespan='%f' %runtime 13 print 'Time Span:'+runtime+' s'
这么看 还是IDL 简单一些