我有这样一门课:
from threading import Thread 
import time
class Timer(Thread): 
    def __init__(self, interval, function, *args, **kwargs): 
        Thread.__init__() 
        self.interval = interval 
        self.function = function 
        self.args = args 
        self.kwargs = kwargs 
        self.start()
    def run(self): 
        time.sleep(self.interval) 
        return self.function(*self.args, **self.kwargs) 我用下面的脚本调用它:
    import timer 
    def hello():
        print \"hello, world
    t = timer.Timer(1.0, hello)
    t.run()得到这个错误,但我找不出原因:unbound method __init__() must be called with instance as first argument
发布于 2009-10-24 02:29:40
您正在执行以下操作:
Thread.__init__() 使用:
Thread.__init__(self) 或者,更确切地说,使用super()
https://stackoverflow.com/questions/1615148
复制相似问题