classAnimal(object):def__init__(self, name, age):
self.name = name
self.age = age
defeat(self):returnf'{self.name} has attribute'classCat(Animal):def__init__(self, name, age, sex):
self.name = name
self.age = age
self.sex = sex
defrun(self):returnf'{self.name} can run'if __name__ =='__main__':#实例化对象时必须执行__init__方法,类中没有,从父类找,父类没有,从object类中找。#python3中使⽤的都是新式类. 如果基类谁都不继承. 那这个类会默认继承 object
a = Cat('Tom',4,'m')print(a.name)print(a.eat())