用python ,怎么实现无限循环(非死循环)?
5 回答
陪伴而非守候
TA贡献1757条经验 获得超8个赞
1 2 3 4 5 6 7 | def loop(init): now = init while 1: yield now now+=1 for i in loop(0): print i |
RISEBY
TA贡献1856条经验 获得超5个赞
import threading##多线程
def a:
while True:
print("hello")
def b:
print("xxxx")
threads=[]
t1=threading.Thread(target=self.a())
threads.append(t1)
t2=threading.Thread(target=self.b())
threads.append(t2)
for t in threads:
t.setDaemon(True)
t.start
添加回答
举报
0/150
提交
取消