Python定时器回调方法

Python定时器回调方法,python,Python,当我运行上面的代码时,我的回调方法从未被触发。我已经试着解决这个问题好几个小时了,但还是想不出来>你从来没有启动过计时器。您需要: from threading import Timer class test_timer(): def __init__(self): self.awesum="hh" self.timer = Timer(1,self.say_hello,args=["WOW"]) def say_hello(self,messa

当我运行上面的代码时,我的回调方法从未被触发。我已经试着解决这个问题好几个小时了,但还是想不出来>你从来没有启动过计时器。您需要:

from threading import Timer

class test_timer():
    def __init__(self):
        self.awesum="hh"
        self.timer = Timer(1,self.say_hello,args=["WOW"])
    def say_hello(self,message):
        self.awesum=message
        print 'HIHIHIIHIH'
        print message
        raise Exception("hi")

if __name__ == '__main__':
    print 'Got to main'
    x=test_timer()
self.timer.start()