自定义异常

class AlexError(Exception):
def __init__(self, msg):
self.message = msg
# def __str__(self):
# return 'sdfsf'
try:
raise AlexError('数据库连不上')
except AlexError as e:
print(e)
posted @ 2018-11-16 10:40  rongye  阅读(78)  评论(0编辑  收藏  举报