我正在制作一个不和谐的机器人并想制作一个计时器,但不使用循环。循环的问题在于它会停止电路的其余部分,直到它完成执行循环。有没有办法解决这个问题?我确实搜索了如何做,但他们都使用了 while x > 60
,这在这种情况下不起作用。
答案 0 :(得分:2)
你需要使用线程,它看起来像这样:
import threading
def func():
times = 0
while times < 10:
print(times)
times += 1;
x = threading.Thread(target=func)
x.start()
n = 100
while n < 110:
n += 1
print(n)
这里两个while循环同时运行