天天看點

python計算某程式運作時間的方法

代碼如下:

import time
startTime =time.clock()
for i in range(10000000):
    a=1
endTime = time.clock()
print('運作時間為: %s 秒' %(endTime - startTime))