在下面的代码中,当我运行以下代码时,为什么它会返回不同的时间。应该一样。
`for i in range(2):
start=time.time()
print(start)
a= np.arange(10).reshape(2,5)
print(a)
end=time.time()
print(end)
dd=datetime.timedelta(seconds = end-start)
print("time diff: ",dd)`
答案 0 :(得分:0)
import time
import numpy as np
import datetime
import psutil, os
p = psutil.Process(os.getpid())
p.nice(psutil.REALTIME_PRIORITY_CLASS)
for i in range(2):
start=time.time()
print(start)
a= np.arange(10).reshape(2,5)
print(a)
end=time.time()
print(end)
dd=datetime.timedelta(seconds = end-start)
print("time diff: ",dd)