Discuss / Python / 练习

练习

Topic source

AL

#1 Created at ... [Delete] [Delete and Lock User]
class Screen(object):
    
    @property # 方法作属性调用
    def width(self): #方法 width
        return self._width #实例变量 _width
    @width.setter
    def width(self, value):
        self._width = value
        
    @property # 方法作属性调用
    def height(self): #方法 width
        return self._height #实例变量 _width
    @height.setter
    def height(self, value):
        self._height = value
        
    @property
    def resolution(self):
        return self._width*self._height

  • 1

Reply