标签:blog put logs col get def inpu 对象 set
类和对象
1 class Rectangle: 2 length = 5 3 width = 4 4 5 def getRect(self): 6 print(‘矩形的长是:%.2f,宽是:%.2f‘%(self.length, self.width)) 7 8 def setRect(self): 9 print ‘请输入长和宽‘ 10 self.length = float(input(‘长:‘)) 11 self.width = float(input(‘宽:‘)) 12 13 def getArea(self): 14 print(‘矩形的面积是:%.2f‘%(self.length*self.width)) 15 16 rect = Rectangle()
标签:blog put logs col get def inpu 对象 set
原文地址:http://www.cnblogs.com/troublemaker/p/7729850.html