python 笔记

子类调用父类函数的方式:

1. super().methord()

2. superClassName.methord(self)

3. super(className,self).methord()

eg:

class People(object):
  def say(self){
    print('People');
  };

class Man(People){
  def say(self){
    print('Man');
  };
  def go(self){
     print('go');
  }
}
# 调用父亲
class SmallMan(Man){
  def say(self){
    print('Small Man');
  };

  def run(self){
    People.say(self);
    super(Man,self).say();
    super().go();
  }
}




你可能感兴趣的:(python 笔记)