-1

我试图每 5 秒后调用一种方法。但是,它似乎只被调用一次并且程序停止执行。这是我正在尝试的代码:

class MyClass(object):
def getData(self):
    print "I am not able to call after every interval"
def main():
    m = MyClass()
    m.getData()

Timer(2.0, main).start()
4

1 回答 1

0
class MyClass(object):
    def getData(self):
        print "I am not able to call after every interval"

def main():
    while "foo" != "bar":
        m = MyClass()
        Timer(2.0, m.getData()).start()

main()
于 2013-09-21T12:52:00.623 回答