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
这是关于作业。然后我赋值就出现了错误
s.weight=1024
s.height=768 Traceback (most recent call last): File "<pyshell#51>", line 1, in <module> s.height=768 AttributeError: can't set attribute
weight可以赋值,但是height却弹出cant set attribute的错误,为什么?不懂
我用的python是3.4.3
weight?是什么 width?height?
Sign in to make a reply
ChuckyYan
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
这是关于作业。然后我赋值就出现了错误
s.weight=1024
weight可以赋值,但是height却弹出cant set attribute的错误,为什么?不懂
我用的python是3.4.3