threading.Timer 返回值

定义
import  threading


class hy_Timer(threading.Timer):
    def __init__(self, interval, function, args=[], kwargs={}):
        self._original_function = function
        super(hy_Timer, self).__init__(
            interval, self._do_execute, args, kwargs)

    def _do_execute(self, *a, **kw):
        self.result = self._original_function(*a, **kw)

    def join(self):
        super(hy_Timer, self).join()
        return self.result

调用
t = hy_Timer(0.3, 函数名)
t.start()
print(t.join())

如果觉得文章不错,可以分享给其他人哟~
原文地址:https://www.cnblogs.com/hany-postq473111315/p/15179944.html