Python 类和实例
2018-04-15 16:42 by xx--, ... 阅读, ... 评论, 收藏, 编辑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参数