这是一个简短的程序,它给了我一个我很难理解的错误:
import time
TIMEOUT_LENGTH = 0.4
TIMEOUT_CHECK = False
STOPPED = True
timeout = 0.0
def start_timer():
global timeout
global STOPPED
global TIMEOUT_CHECK
TIMEOUT_CHECK = False
STOPPED = False
timeout = time.time() + TIMEOUT_LENGTH
def stop_timer():
global STOPPED
global TIMEOUT_CHECK
TIMEOUT_CHECK = False
STOPPED = True
def timeout():
global timeout
global STOPPED
global TIMEOUT_CHECK
currTime = time.time()
if (currTime > timeout) and (STOPPED == False):
TIMEOUT_CHECK = True
return TIMEOUT_CHECK
start_timer()
print timeout()
运行它给了我:
Traceback (most recent call last):
File "prob.py", line 34, in <module>
print timeout()
TypeError: 'float' object is not callable
在我看来,我并没有试图打电话currTime
或timeout
。我不明白这里发生了什么?