class Rectangle: def __init__(self,length,weight):#初始化方法 self.length = length self.weight=weight def area(self): return self.length * self.weight def __repr__(self): return str(self.length*self.weight) class square(Rectangle): def __call__(self):#call方法实现类的名称可调用 print((self.length+self.weight)*2)#调用时打印边长 sq = square(20,33) print(sq) sq()#类的实例可调用 结果: 660 106