Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
处理python包中的特定异常_Python_Exception_Exception Handling_Python 3.7 - Fatal编程技术网

处理python包中的特定异常

处理python包中的特定异常,python,exception,exception-handling,python-3.7,Python,Exception,Exception Handling,Python 3.7,我想以特定的方式处理py_vollib/py_lets_be_rational中的以下异常 py_lets_be_rational.exceptions.BelowIntrinsicException: The volatility is below the intrinsic value. 尝试此方法但未成功: from py_vollib.black.implied_volatility import implied_volatility as impl_vol_b from py_let

我想以特定的方式处理py_vollib/py_lets_be_rational中的以下异常

py_lets_be_rational.exceptions.BelowIntrinsicException: The volatility is below the intrinsic value.
尝试此方法但未成功:

from py_vollib.black.implied_volatility import implied_volatility as impl_vol_b
from py_lets_be_rational.exceptions import BelowIntrinsicException

try:
    call_vol = impl_vol_b(discounted_option_price, F, K, r, t, type)
except BelowIntrinsicException as e:
    if str(e) != 'The volatility is below the intrinsic value':
        raise
    else:
        call_vol = 0
我做错了什么?如果有任何帮助,我们将不胜感激。

请看,您错过了句子末尾的句号:

if str(e) != 'The volatility is below the intrinsic value.':

我看不出这项检查有什么意义,因为创建异常时总是使用这条消息。

oops很抱歉,我发现了这一点,并认为我实际上没有发送问题。