Gxlsystem TIY Editor
Gxlsystem 在线教程
改变方向
暗黑模式
python_inheritance_add_prop_2.py:
class Person: def __init__(self, fname, lname): self.firstname = fname self.lastname = lname def printname(self): print(self.firstname, self.lastname) class Student(Person): def __init__(self, fname, lname, year): super().__init__(fname, lname) self.graduationyear = year x = Student("Elon", "Musk", 2019) print(x.graduationyear)