自定义异常
1 #!/usr/bin/env python 2 # coding=utf-8 3 4 class HexmException(Exception): 5 6 def __init__(self, msg): 7 self.message = msg 8 9 def __str__(self): 10 return self.message 11 12 try: 13 raise HexmException('hexm的异常') 14 except HexmException as e: 15 print(e)