大鹏

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

 

 

 

 

#我的代码

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()

 另一个版本

 

posted on 2018-12-10 21:43  pf42280  阅读(3457)  评论(0编辑  收藏  举报