Learning immediately: https://edu.csdn.net/course/play/24797/282200?utm_source=blogtoedu
# Raise an exception use class Test47: @property def theAge(self): return self.__age @theAge.setter def theAge(self, age): if age > 30 or age < 10: # Raise # default RuntimeError # raise ValueError raise OSError (age, 'the age of input error') else: self.__age = age # T47 = Test47 () # t47.theAge = 9 try: t47 = Test47 () t47.theAge = 8 except OSError as e: print (e) print(e.errno) print(e.strerror) print(e.args)