class Rectangle():
length=3.5
width=5
def getRect(self):
print('这个矩形的长是:%.2f,宽是:%.2f' % (self.length,self.width))
def setRect(self):
print('请输入矩形的长和宽...')
self.length = float(input('长: '))
self.width = float(input('宽: '))
#print('长:%d'%self.longth)
#print('宽:%d'%self.width)
def getArea(self):
return self.length*self.width
print(area)
使用类对象,计算一个矩形的面积,
length=3.5
width=5
是初值,如果不设置,就直接待入










