import time
start = time.clock()
print(start)
sum = 0
for i in range(1000000):
sum +=i
end = time.clock()
print(end)
yongshi = end - start
print("总耗时为:%s" % yongshi)
time.clock()#此方法在python 3.3中将被弃用,python3.8 中将删除use time
import time
start = time.time()
sum = 0
for i in range(1000000):
sum +=i
time.sleep(2)
end = time.time()
yongshi = end - start
print("总耗时为:%s" % yongshi)
import datetime
starttime = datetime.datetime.now()
print(starttime)
sum = 0
for i in range(100000000):
sum += i
#long running
endtime = datetime.datetime.now()
print(endtime)
print(endtime - starttime)