用python ,怎么實現(xiàn)無限循環(huán)(非死循環(huán))?
5 回答

萬千封印
TA貢獻(xiàn)1891條經(jīng)驗 獲得超3個贊
你在循環(huán)里面 加個 暫停的語句 就可以了
import time
x=0
while True:
x=x+1
print x
time.sleep(5)

陪伴而非守候
TA貢獻(xiàn)1757條經(jīng)驗 獲得超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貢獻(xiàn)1856條經(jīng)驗 獲得超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
提交
取消