class Screen(object):
@property
def width(self):
return self.width
@width.setter
def width(self, value):
self.width = value
def height(self):
return self.height
@height.setter
def height(self, value):
self.height = value
def resolution(self):
return self.width * self.height
File "C:\Software\Coding learning\PythonApplication1\PythonApplication1\module5.py", line 8 in width
不理解为什么不加下划线会出现这个错误
Python中self用法详解_CLHugh的博客-CSDN博客_python self,这里面讲了,可以看一下
因為你width本身就是方法了,你怎麼又用来作変量呢
文中有讲解
Sign in to make a reply
A22B9S
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 self.width * self.height
File "C:\Software\Coding learning\PythonApplication1\PythonApplication1\module5.py", line 8 in width
File "C:\Software\Coding learning\PythonApplication1\PythonApplication1\module5.py", line 8 in width
File "C:\Software\Coding learning\PythonApplication1\PythonApplication1\module5.py", line 8 in width
File "C:\Software\Coding learning\PythonApplication1\PythonApplication1\module5.py", line 8 in width
File "C:\Software\Coding learning\PythonApplication1\PythonApplication1\module5.py", line 8 in width
不理解为什么不加下划线会出现这个错误