编程语言
首页 > 编程语言> > 廖雪峰python #@property使用

廖雪峰python #@property使用

作者:互联网

请利用@property给一个Screen对象加上width和height属性,以及一个只读属性resolution:

class Screen(object):
    @property
    def width(self):
        return self._width
    @width.setter
    def width(self,value):
        self._width=value
    @property
    def height(self):
        return self._height
    @height.setter
    def height(self,value):
        self._height=value
    @property
    def resolution(self):
        return 786432

标签:python,self,雪峰,height,width,._,property,def
来源: https://blog.csdn.net/linuscool/article/details/114307119