2017-02-25 90 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

相關問題