telnetlib.Telnet.__init__(self, host, port, timeout)
您需要添加显式,self
因为telnet.Telnet.__init__
它不是 绑定方法 ,而是非 绑定方法 ,即不分配实例。因此,在调用它时,您需要显式传递实例。
>>> Test.__init__
<unbound method Test.__init__>
>>> test().__init__
<bound method Test.__init__ of <__main__.Test instance at 0x7fb54c984e18>>
>>> Test.__init__()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unbound method __init__() must be called with Test instance as first argument (got nothing instead)