node2:/tmp#cat s1.py
class Moster():
def __init__(self,hp=100):
self.hp=hp
def run(self):
print('aaaaaaaaaa')
class animals(Moster):
def __init__(self,hp=89):
super().__init__(hp)
#pass
x=animals(80)
print(x.run())
print(x.hp)
node2:/tmp#python3 s1.py
aaaaaaaaaa
None
80
父类中初始化了某些属性,子类不需要重复初始化