When a class is defined, it can inherit from other existing classes. The classes created by inheritance become subclasses. The inherited classes are called parent classes, base classes, or superclasses.Copy the code
Class Person(): # Def __init__(self,name,age): Self. name = name self.age = age def speak(self): print(self) self.name = name self.age = age def speak(self): print(self) Class Teacher(Person): def __init__(self,name,age,weight): Person.__init__(self, name, age) # self. Weight = weight def write(self): print('... Def speak(self): print('%s is talking loudly. T = '% self. The name) the Teacher (' zhang SAN, 28, 50) t.w rite () t.s peak ()Copy the code
Print the result
Is making a career change…
Zhang SAN is talking loudly.