用多线程并行处理while,需要 print x的话,用列队获取。考虑多线程,开一个线程来无限累加。import threading##多线程def a:while True:print("hello")def b:print("xxxx")threads=[]
用python ,怎么实现无限循环非死循环?
你在循环里面 加个 暂停的语句 就可以了
import time
x=0
while True:
x=x+1
print x
time.sleep(5)2015-04-18
用多线程并行处理while,需要 print x的话,用列队获取。
考虑多线程,开一个线程来无限累加。
import threading##多线程def a:while True:print("hello")def b:print("xxxx")threads=[]
扩展资料:
Python 是一门有条理的和强大的面向对象的程序设计语言,类似于Perl, Ruby, Scheme, Java。自从20世纪90年代初Python语言诞生至今,它已被逐渐广泛应用于系统管理任务的处理和Web编程。Python在设计上坚持了清晰划一的风格,这使得Python成为一门易读、易维护,并且被大量用户所欢迎的、用途广泛的语言。
参考资料:百度百科-Python
2018-10-07
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.start2017-10-25
while 1==1: print 'Hello'#这里执行不到print 'xxxxxxx'2018-07-04
用多线程并行处理while
需要 print x的话 用列队获取2017-10-21
x = 0
while True:
x += 1
print(f'{x},',end='')2019-05-06
import timewhile True:_____dosomething_____time.sleep(60)2017-07-17
考虑多线程,开一个线程来无限累加。2018-04-04
def loop(init): now = init while 1: yield now now+=1for i in loop(0): print i2018-04-03
while True: print 'Hello'#这里执行不到print 'xxxxxxx'2015-09-25