Discuss / Python / 交作业啦

交作业啦

Topic source

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

s = Screen() s.width = 1024 s.height = 768 print('resolution =', s.resolution) resolution = 786432


  • 1

Reply