class Player(object): def __init__(self,name,age,life): self.name=name self.age=age self.life=life class Player1(object): __slots__=("name","age","life") def __init__(self,name,age,life): self.name=name self.age=age self.life=life p1=Player("a",12,33) p1.aa="2334" p2=Player1("b",12,33) p2.bb=21323## 报错 print(dir(p2)) print(set(dir(p1))-set(dir(p2)))