如何修改类Auto,以确保主有效?
class Tool:
def __init__(self, target):
self.target = target
class Wifi:
def __init__(self):
pass
def connect(self, id):
print id
self.target.write("xxxxxxxxx")
def verify(self)
pass
if __name__ == '__main__':
T = Tool(target)
T.Wifi.connect("dev")
我想像redmine那样模仿模块:
from redmine import Redmine
redmine = Redmine(REDMINE_URL, key = REDMINE_API_KEY)
redmine.issue.get('16520')
答案 0 :(得分:3)
这不是通过嵌套类完成的,但具有组合:
class Tool:
def __init__(self, target):
self.target = target
self.wifi = Wifi(self.target)
class Wifi:
def __init__(self, target):
self.target = target
def connect(self, id):
print id
self.target.write("xxxxxxxxx")
def verify(self)
pass
if __name__ == '__main__':
T = Tool(target)
T.wifi.connect("dev")