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
?