#我的代码 class Rectangle: length = float(input('长:')) width = float(input('宽:')) def setRect(self): print("打印长和宽") self.length = length self.width = width def getRect(self): print("这个矩形的长是%.2f,宽是%.2f" % (self.length,self.width)) def getArea(self): return self.length * self.width p = Rectangle()
另一个版本