用python ,怎么实现无限循环(非死循环)?

用python ,怎么实现无限循环(非死循环)?


眼眸繁星
浏览 4971回答 5
5回答

幕布斯7119047

1234while 1==1:    print 'Hello'#这里执行不到print 'xxxxxxx' 

万千封印

你在循环里面 加个 暂停的语句 就可以了import timex=0while True:x=x+1print xtime.sleep(5)

陪伴而非守候

1234567def loop(init):    now = init    while 1:        yield now        now+=1for i in loop(0):    print i 

RISEBY

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 
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python