Traceback (most recent call last):
File "C:/Users/Administrator/Desktop/11.py", line 26, in <module>
print(s.resolution)
File "C:/Users/Administrator/Desktop/11.py", line 22, in resolution
return self.width*self.height
AttributeError: 'Screen' object has no attribute '_Screen__height'
折腾没完没了过瘾
class Screen(object): @property def width(self): return self.width @width.setter def width(self,value): if not isinstance(value,int): raise ValueError('TypeError') self.width=value
s=Screen() s.width=1024 s.heigth=768 print(s.resolution)
Traceback (most recent call last): File "C:/Users/Administrator/Desktop/11.py", line 26, in <module> print(s.resolution) File "C:/Users/Administrator/Desktop/11.py", line 22, in resolution return self.width*self.height AttributeError: 'Screen' object has no attribute '_Screen__height'