1、计时代码:
import time
def func():
for i in range(1000):
pass
if __name__ == '__main__':
start = time.time()
func()
end = time.time()
#计算程序运行时间end-start,并打印
print("func cost",end-start,"seconds")
1、计时代码:
import time
def func():
for i in range(1000):
pass
if __name__ == '__main__':
start = time.time()
func()
end = time.time()
#计算程序运行时间end-start,并打印
print("func cost",end-start,"seconds")