Jos*_*der 4 python exception version python-3.x
我有一个简单的库作为.py文件分发.如果从Python 2而不是Python 3调用库,我想引发一个异常:
def _check_version():
if sys.version_info < (3,):
raise _____Exception('This library depends on Python 3 strings. Please ensure you are using Python 3 instead of Python 2')
Run Code Online (Sandbox Code Playgroud)
我应该提出什么内置异常?(如何填写上面的空白?)我在内置异常中找到的最接近的异常是NotImplementedError.DeprecationWarning感觉很接近,但在这种情况下,例外情况更合适.
| 归档时间: |
|
| 查看次数: |
47 次 |
| 最近记录: |