2017-02-25 88 views
0

为什么一个简单的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() 
+0

请在这里添加完整的引用! – Arman

+0

回溯(最近的通话最后): –

+0

不是这样,完整的错误追溯到你的问题并编辑它。 – Arman

回答

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() 
+0

谢谢但冒号在实际的代码中使用。输入问题时我错过了。 –

+0

这是一个'语法错误',与'TypeError'无关 – Arman

相关问题