【发布时间】:2019-06-12 13:35:53
【问题描述】:
我处理数据,对于某些示例,数据存在问题。 Python 提出了一个
ValueError:残差在初始点不是有限的。
是否有可能仅通过消息"Residuals are not finite in the initial point." 捕获值错误?
我试过了:
try:
[code that could raise the error]
except Exception as e:
if e=='ValueError(\'Residuals are not finite in the initial point.\')':
[do stuff I want when the Residuals are not finite]
else:
raise e
但它仍然一直引发错误。有没有办法实现我的想象?
谢谢
【问题讨论】:
标签: python exception-handling try-catch valueerror raise