天天看点

python计算某程序运行时间的方法

代码如下:

import time
startTime =time.clock()
for i in range(10000000):
    a=1
endTime = time.clock()
print('运行时间为: %s 秒' %(endTime - startTime))