super

简介

1
2
3
4
5
6
7
8
9
10
11
12
13
# coding:utf-8

class Parent():
def __init__(self,p):
print('hello i am parent %s' % p)

class Child(Parent):
def __init__(self,c,p):
print('hello i am %s' % c)
super().__init__(p) # 用super调用父类

if __name__ == '__main__' :
c = Child(c='child',p='parent')