python中的异常子类

时间:2017-11-25 23:41:48

标签: python python-3.x exception python-import

当我尝试导入Exception的子类时,我得到了ImportError: cannot import name Empty。这是代码:

文件名:exceptions.py

class Empty(Exception):
  """Error attempting to access an element from an empty container."""
  pass

文件名:main.py

from exceptions import Empty

我该如何解决这个问题?

0 个答案:

没有答案