我可以多次使用while循环吗?我该怎么做呢?例如,在这段代码中,我想让它检测字符串“左转”。如果它这样做了,按钮将发送一个信号,如果它被按下。我现在的问题是,如何同时对其他字符串进行循环检查,如“右转”、“走第一个出口”?
while instruction == "turn left":
if (GPIO.input(12) == False):
print("button press")
assistant.start_conversation()
break
else:
GPIO.output(3, GPIO.HIGH)
sleep(0.3)
GPIO.output(3, GPIO.LOW)
sleep(0.3)https://stackoverflow.com/questions/50641069
复制相似问题