class A(object): def __init__(self, host, user, pwd, port): self.host = host self.user = user self.pwd = pwd self.port = port ob_vs = Vsphere("172", "local", "Server", 443)
class A(object)定义一个A类继承于object
# def _init_ 类似于构造函数,第一个参数必须是self
self.host = host为类的属性赋值
ob_vs = Vsphere.__init__("172","local","Server",443) 创建实例时不需要传self参数