自定义异常

 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)

 

posted @ 2016-11-27 12:20  hexm  阅读(136)  评论(0编辑  收藏  举报
联系我:xiaoming.unix@gmail.com