Discuss / Python / 求解,为什么一直提示 self 没定义

求解,为什么一直提示 self 没定义

Topic source

class Screen(object):

    @property

    def width(self,width,value):

        return self._width

    @width.setter

    def width(self,value):

        self._width = value

    @property

    def height(self,height,value):

        return self._height

    @height.setter

    def width(width,value):

        self._height = value

    @property

    def resolution(self):

        return self._height * self._width

s = Screen()

s.width = 1024

s.height = 768

print('resolution =', s.resolution)


  • 1

Reply