p 继承
class Animal: def __init__(self,name,agr,hp): self.name = name self.agr = agr self.hp = hp class Dog(Animal): def __init__(self,name,agr,hp,kind): Animal.__init__(self,name,agr,hp) self.kind = kind def bite(self,person): person.hp -= self.agr class Person(Animal): def __init__(self,name,agr,hp,sex): Animal.__init__(self,name,agr,hp) self.sex = sex jin = Dog('金老板',100,30,'teddy') print(jin.__dict__)