class Animals():
def breath(self):
print("breathing")
def move(self):
print("moving")
def eat(self):
print("eating food")
class Mamals(Animals):
def breastfeed(self):
print("feeding young")
class Cats(Mamals):
def __init__(self,spots):
self.spots = spots
def catch_mouse(self):
print("catch mouse")
def left_foot_forward(self):
print("left foot forward")
def left_foot_backforward(self):
print("left foot backforward")
def dance(self):
self.left_foot_forward()
self.left_foot_backforward()
self.left_foot_forward()
self.left_foot_backforward()
kitty = Cats(10)
print(kitty.spots)
kitty.dance()
kitty.breastfeed()
kitty.move()
eg.1.父类的调用:Cats()调用Mammals(),Mammals()调用Animals()
2.同时要注意实例化的步骤
output:
10
left foot forward
left foot backforward
left foot forward
left foot backforward
feeding young
moving调用