我只是试图将self
和另外两个参数传递给一个线程,但每次都会遇到一个错误。在
我试着跟踪其他样品,但到目前为止没有任何效果。在
class X:
def start(self):
newStartupThread = threading.Thread(target=self.launch, args=(t1_stop,
self.launchAdditionalParams))
newStartupThread.name = "ClientLaunchThread%d" %
(self.launchAttemptCount+1)
newStartupThread.daemon = True
newStartupThread.start()
def launch(self, test, additionalParams):
pass
我得到了这个错误:
^{pr2}$**编辑代码以显示它在类中
根据
self
的存在,我假设这是在一个类中。在对我来说很好,输出
^{pr2}$launch
是函数,不是方法。只有方法需要self
参数。只要去掉自变量,它就会起作用:如果是在类中,则必须执行以下两种操作之一:
someClass.launch(arg1, arg2)
)self
参数使其成为static method相关问题 更多 >
编程相关推荐