本文實(shí)例講述了Python計(jì)算程序運(yùn)行時(shí)間的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:
代碼如下:
import time
def start_sleep():
time.sleep(3)
if __name__ == '__main__':
#The start time
start = time.clock()
#A program which will run for 3 seconds
start_sleep()
#The End time
end = time.clock()
print("The function run time is : %.03f seconds" %(end-start))
# End
希望本文所述對大家的Python程序設(shè)計(jì)有所幫助。
更多信息請查看IT技術(shù)專欄