当我执行此代码时
import class3,thread
t3 = class3.test3
thread.start_new_thread(t3.func3,())
其中class3
是
class test3(object):
def func3():
while 1:
print "working!!"
我收到错误:
< unbound method test3.func3>
启动的线程中未处理的异常
此错误的含义是什么,我该如何解决?
答案 0 :(得分:0)
调用它,看看会发生什么:
TypeError: unbound method func3() must be called with test3 instance as first argument (got nothing instead)
您必须使func3
成为实例方法并初始化您的类:
class test3(object):
def func3(self):
while True:
print "working!!"
t3 = test3()
或者func3
staticmethod
:
class test3(object):
@staticmethod
def func3():
while True:
print "working!!"