网站Logo ZhangZH的知识笔记

python学习笔记

australian-shepherd
17
2026-03-13

类与类继承

class Person:
    def __init__(self,name,age):
        self.name = name
        self.age  = age
    def PrintPersonInformation(self):
        print(f"Name={self.name},Age={self.age}")

class Student(Person):
    def __init__(self, name, age, score):
        super().__init__(name,age)
        self.score = score
    def PrintStudentInformation(self):
        print(f"Name={self.name},Age={self.age},Score={self.score}")



if __name__ == "__main__":
    
    Stu1 = Student( name="Stu1", age = 19, score = 99 )
    Stu1.PrintStudentInformation()

字典

装饰器

动物装饰