标签:start time second nbsp int python程序 strong 程序 cond
方法1
import datetime
import time
starttime = datetime.datetime.now()
#long running
time.sleep(2)
endtime = datetime.datetime.now()
str="run time: %d seconds" % ((endtime - starttime).seconds)
print(str)
方法2
import datetime
import time
start = time.time()
time.sleep(2)
end = time.time()
str="run time: %d seconds" % ( end-start)
print(str)
方法3
import datetime
import time
start = time.clock()
time.sleep(2)
end = time.clock()
str="run time: %d seconds" % ( end-start)
print(str)
标签:start time second nbsp int python程序 strong 程序 cond
原文地址:https://www.cnblogs.com/emanlee/p/14333309.html