Python AssertionError:group参数现在必须为None
我使用PIR传感器来确定入侵者是否存在。如果入侵者存在,它将进入睡眠1分钟,现在我必须重置睡眠时间,为此我使用线程,但它显示断言错误,请帮助我,下面是我的代码Python AssertionError:group参数现在必须为None,python,raspberry-pi,iot,python-multithreading,Python,Raspberry Pi,Iot,Python Multithreading,我使用PIR传感器来确定入侵者是否存在。如果入侵者存在,它将进入睡眠1分钟,现在我必须重置睡眠时间,为此我使用线程,但它显示断言错误,请帮助我,下面是我的代码 from threading import Thread, Event import time import RPi.GPIO as GPIO class MyThread(Thread): def __ini(self, timeout=60): self.intruder_spotted = Event(
from threading import Thread, Event
import time
import RPi.GPIO as GPIO
class MyThread(Thread):
def __ini(self, timeout=60):
self.intruder_spotted = Event()
self.timeout = timeout
self.daemon = True
def run(self):
while True:
if self.intruder_spotted.wait(self.timeout):
self.intruder_spotted.clear()
print("Intruder")
else:
print("No intruder")
t = MyThread(60)
GPIO.setmode(GPIO.BCM)
GPIO.setup(18,GPIO.IN)
try:
t.start()
while True:
i=GPIO.input(18)
if i==1:
t.intruder_spotted.set()
time.sleep(1)
except KeyboardInterrupt:
GPIO.cleanup()
exit(0)
需要更新类my Thread的int。它是
\uuuu init\uuuu
而不是class MyThread(Thread):
def__init__(self, timeout=60):
super(MyThread, self).__init__()
self.intruder_spotted = Event()
self.timeout = timeout
self.daemon = True
需要更新类my Thread的int。它是
\uuuu init\uuuu
而不是class MyThread(Thread):
def__init__(self, timeout=60):
super(MyThread, self).__init__()
self.intruder_spotted = Event()
self.timeout = timeout
self.daemon = True
请看,您应该将错误消息的全文编辑到您的问题中,因为目前除了您之外,没有人知道哪一行有错误或错误本身的全部细节。看见另外,您是否打算使用方法
\uu ini()
?这不会被打电话的。正确的名称是\uuuu init\uuuu()
,您可能打算调用\uuu super\uuuu()
,以确保线程已完全初始化。请参阅,您应该将错误消息的全文编辑到问题中,因为目前除了您之外,没有人知道哪一行有错误或错误本身的全部细节。看见另外,您是否打算使用方法\uu ini()
?这不会被打电话的。正确的名称是\uuuu init\uuuu()
,您可能打算调用\uuuu super\uuuu()
,以确保线程已完全初始化。