面试题答案
一键面试class CustomException(Exception):
def __init__(self, *args):
self.extra_args = args
super().__init__(*args)
try:
raise CustomException('常规异常信息', '额外参数1', '额外参数2')
except CustomException as e:
result = {
'常规异常信息': str(e),
'额外参数': list(e.extra_args)
}
print(result)