异常处理
try:# do somethingexcept 异常类型1:# do somethingexcept 异常类型2:# do something...except:# do somethingfinally:# try正常结束或except异常处理结束都会执行
自定义异常
class MyException(Exception):def __init__(self,message):super().__init__(message)try:passexcept Exception:raise MyException('出错辣~')
