python中的异常。给定定义,如何在代码内部调用它?

python中的异常。给定定义,如何在代码内部调用它?,python,Python,在库中定义了以下异常: exception paramiko.ssh_exception.AuthenticationException Exception raised when authentication failed for some reason. It may be possible to retry with different credentials. (Other classes specify more specific reasons.) 在我的代码中,如果我写: exc

在库中定义了以下异常:

exception paramiko.ssh_exception.AuthenticationException
Exception raised when authentication failed for some reason. It may be possible to retry with different credentials. (Other classes specify more specific reasons.)
在我的代码中,如果我写:

except AuthenticationException:
我犯了一个错误

如果我写:

except paramiko.AuthenticationException:
它起作用了

为什么不:

except paramiko.ssh_exception.AuthenticationException:
根据定义,我怎么知道写什么

库paramiko显然已导入:

import paramiko

我猜
paramiko
包有以下
\uuuu init\uuuu.py

from .ssh_exception import *
然后,如果您
导入paramiko
,您将拥有
paramiko
下的所有内容,而无需额外的分支