每次我运行代码时,它都会说:
Traceback (most recent call last):
File "/Users/syedrishad/PycharmProjects/OpenCVPython/venv/Reaction Test.py", line 14, in <module>
tic = time.clock()
AttributeError: module 'time' has no attribute 'clock'
我知道它已被删除,但现在我不知道如何更改程序。有人可以修复它。应该是反应测试。
import time, random
rounds = int(input('How many rounds do you want to play?'))
times = []
for i in range(0,rounds):
print('when I say __GO__ you hit ENTER!. got it?')
time.sleep(1)
print('ready')
time.sleep(1)
print('steady')
time.sleep(random.randint(2,5))
print('#####__GO__######')
tic = time.clock()
a = input()
toc = time.clock()
timeSpent = toc-tic
times.append(timeSpent)
print('your time was '+str(timeSpent) + ' seconds')
print('fastest time was ' + str(min(times)))
print('slowest time was ' + str(max(times)))
average = sum(times)/len(times)
print('the average time was ' + str(average))
任何帮助将不胜感激。我已经为此困扰了一段时间。