为什么简单的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 :(得分: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()