用super初始化父类的参数,这样子类才能使用
import numbers
from tkinter import scrolledtext
class People():
def __init__(self, name, age):
self.name = name
self.age = age
def get_name(self):
print(f'my name is {self.name}')
def get_age(self):
print(f'my name is {self.age}')
class Student(People):
def __init__(self,name,age,number,score):
super(Student,self).__init__(name,age)
self.number = number
self.score = score
def get_number(self):
print(f"my_number is {self.number}")
def get_score(self):
print(f"my_score is {self.score}")
if __name__ == "__main__":
student = Student("Tom",38,27,85)
student.get_name()
student.get_age()
student.get_number()
student.get_score()