摘要:
直接在类里定义类的属性class className(object): sex = 'male'12在构造函数里定义属性class className(object): def __init__(self, name, sex): self.name = name self.sex = sex123 阅读全文
摘要:
多态的要素继承重写方法实例class Program(object): name = 'Mike' def __init__(self, age, sex, weight): self.age = age self._sex = sex self.__weight = weight def intr 阅读全文
摘要:
定义类的继承class DerivedClassName(BaseClassName): <statement1> ... <statementN>1234继承的子类会继承父类的属性与方法也可以重新自定义方法 , 覆盖父类的属性与方法用super()调用父类的方法class A(http://www 阅读全文
摘要:
Python允许从多个父类继承 , 称为多重继承class A(object): def __init__(self, a): print 'init A...' self.a = a class B(A): def __init__(self, a): super(B, self).__init_ 阅读全文