__slots__为什么没有报错,依然赋值了没有的age
class Person:
__slots__ = ('name','gender')
def __init__(self,name,gender):
self.name = name
self.gender = gender
class Student(Person):
__slots__ = ('name', 'gender','score')
def __init__(self, name, gender,score):
super().__init__(name, gender)
self.score = score
Student.age = 12
s = Student('qrh','男',88)
print(s.name,s.gender,s.score,s.age) #》》qrh 男 88 12