text: #!/usr/bin/env python3
  # -*- coding: utf-8 -*-
  
  class Student(object):
  
      @property
      def score(self):
          return self._score
  
      @score.setter
      def score(self, value):
          if not isinstance(value, int):
              raise ValueError('score must be an integer!')
          if value < 0 or value > 100:
              raise ValueError('score must between 0 ~ 100!')
          self._score = value
  
  # 把一个getter方法变成属性，只需要加上@property就可以了，
  # 此时，@property本身又创建了另一个装饰器@score.setter，负责把一个setter方法变成属性赋值
  
  # s = Student()
  # s.score = 60
  # print(s.score)
  #
  # s.score = 9999
  # print(s.score)
  
  # 只读属性就是不设置setter
  
  # test
  class Screen(object):
      @property
      def width(self):
          return self._width
      @width.setter
      def width(self, width):
          self._width = width
  
      @property
      def height(self):
          return self._height
  
      @height.setter
      def height(self, height):
          self._height = height
  
      @property
      def resolution(self):
          return self._width * self._height
  
  s = Screen()
  s.width = 1024
  s.height = 768
  print('resolution =', s.resolution)
  if s.resolution == 786432:
      print('测试通过!')
  else:
      print('测试失败!')