从Make 2 functions run at the same time使用线程。它可以同时实现两种功能。是否可以在try except块中使用线程调用函数?你知道吗
import threading
from threading import Thread
import time
def queryRepeatedly():
while True:
while True:
try:
Thread(target = foo).start()
Thread(target = bar).start()
print ''
except:
continue
else:
break
def foo():
print 'foo'
time.sleep(1)
def bar():
print 'bar'
time.sleep(3)
queryRepeatedly()
这是我的代码不工作,我需要运行两个功能分别尝试除了块。我该怎么办?你知道吗
我想这可能就是你想要的:
相关问题 更多 >
编程相关推荐