面试题答案
一键面试class CustomException(Exception):
pass
try:
try:
raise CustomException("这是自定义异常")
except CustomException as e:
raise ValueError("这是包含自定义异常原因的新异常") from e
except ValueError as ve:
print(f"捕获到异常: {ve}")
print(f"异常原因: {ve.__cause__}")