python raise...from... 意义
一、raise **Error('') from exc写法
代码实例
except Exception as exc:
raise **Error('') from exc
运行后,控制台输出2个异常位置和原因,并在两个异常中间提示“The above exception was the direct cause of the following exception:”(上述异常是以下异常的直接原因)
二、raise **Error('') from None写法
代码实例
except Exception as exc:
raise **Error('') from None
运行后,控制台输出1个异常和原因(自定义的异常和原因)
总结
可以通过from控制异常输出,输出简易信息还是完整信息,便于问题定位