标签:cep final color err spl sel src nal span
1 try 2 3 code 4 5 except (error1,error2) as e: 6 7 print(e) 8 9 except Exception as e 抓住所有错误,不建议用 10 11 print(‘未知错误’,e) 12 13 else: 14 15 print(‘一切正常‘) 16 17 Finally: 18 19 print(‘不管有没有错,都执行‘)’
自定义异常
1 class ShaohuiException(Exception) 2 def __init__(self,msg): 3 self.message=msg 4 #def __str__(self): 5 # return self.message 6 7 8 try 9 raise ShaohuiException(‘我的异常’) 10 except ShaohuiException as e: 11 print(e)
标签:cep final color err spl sel src nal span
原文地址:https://www.cnblogs.com/liushaohui/p/9759969.html