亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

用python ,怎么實現無限循環(非死循環)?

用python ,怎么實現無限循環(非死循環)?

眼眸繁星 2019-03-14 14:10:00
用python ,怎么實現無限循環(非死循環)?
查看完整描述

5 回答

?
幕布斯7119047

TA貢獻1794條經驗 獲得超8個贊


1

2

3

4

while 1==1:

    print 'Hello'

#這里執行不到

print 'xxxxxxx'

 


查看完整回答
反對 回復 2019-03-19
?
萬千封印

TA貢獻1891條經驗 獲得超3個贊


你在循環里面 加個 暫停的語句 就可以了

import time
x=0
while True:
x=x+1
print x
time.sleep(5)


查看完整回答
反對 回復 2019-03-19
?
陪伴而非守候

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

 


查看完整回答
反對 回復 2019-03-19
?
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


 


查看完整回答
反對 回復 2019-03-19
  • 5 回答
  • 0 關注
  • 5045 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號