0
我有3个文件。 xxx导入xxx2和xxx2导入xxx3哪一个引发OppsError异常。从python中的sub.submodule捕获明确定义的异常
xxx3.py:
class OppsError(Exception):pass
def go():
raise OppsError()
xxx2.py:
import xxx3
xxx3.go()
xxx.py:
try:
import xxx2
except xxx3.OppsError:
print 'ops'
当我运行xxx.py我得到错误NameError: name 'xxx3' is not defined
。在xxx内部导入xxx3只能抓到OppsError
?