继承与threading.Thread实现有返回值的子类MyThread
import threading
class MyThread(threading.Thread):
def __init__(self,func,args=()):
super(MyThread,self).__init__()
self.func = func
self.args = args
def run(self):
self.res = self.func(*self.args)
def getResult(self):
try:
return self.res
except Exception:
return None
欢迎进(Q)群,帮你解决问题: