在python中記錄程序的運行時間,具體方法如下:
1.使用time函數(shù)
import time
time_start=time.time()
time_end=time.time()
print('Running time:{} seconds'.format(time_start - time_end))
2.使用datetime函數(shù)
import datetime
time_start = datetime.datetime.now()
time_end = datetime.datetime.now()
print (time_end - time_start).seconds