输入错误:'float object not callable'

时间:2017-02-25 20:41:42

标签: python

为什么简单的time.sleep(1)语句会导致:

Type error : 'float' object not callable?

代码如下:

try:
    while True
        time.sleep(10)
        current_state = GPIO.input(pir_sensor)
        if current_state ==1:
            print "PIR Activated"
except KeyboardInterrupt:
    GPIO.cleanup()

1 个答案:

答案 0 :(得分:0)

可能不是因为time.sleep(10) 在第二行,while循环缺少一个冒号:

try:
    while True: # <-- Added colon here
        time.sleep(10)
        current_state = GPIO.input(pir_sensor)
        if current_state == 1:
            print "PIR Activated"
except KeyboardInterrupt:
    GPIO.cleanup()