我正在学习以下代码:
class TestApp(TestWrapper, TestClient):
def __init__(self, ipaddress, portid, clientid):
TestWrapper.__init__(self)
TestClient.__init__(self, wrapper=self)
self.connect(ipaddress, portid, clientid)
thread = Thread(target = self.run)
thread.start()
setattr(self, "_thread", thread)
self.init_error()
我对它的线程组件很感兴趣,我不明白setattr在这里做什么,有人能解释一下吗?在
非常感谢
函数将值指定给所提供对象的属性。例如:
setattr(objectA, 'attr', 'foo')
相当于x.foobar = 'foo'
。在在您的代码中:}。在
setattr(self, "_thread", thread)
相当于{有关详细信息,请访问python_setattr
我希望这对你有帮助!在
相关问题 更多 >
编程相关推荐