我想问一下这个例外情况

时间:2015-06-04 05:55:03

标签: python class exception

这是我的代码

class E3Exception(Exception):
  pass

class E3OddException(E3Exception):
  pass

def raiser (x):
  if (int(x)%2==1):
    raise E3OddException
  elif (int(x)%2==0):
    x=int(x)
  elif (x=='CSC148'):
    raise E3Exception('Hi Brian')
  elif (isinstance(x, str)==True & isinstance(int(x), int)==False &   x!='CSC148'): 
    raise ValueError
  else:
    raise TypeError    

我尝试运行加注(CSC148),但我一直收到以下错误,有人知道为什么吗?

Traceback (most recent call last):
File "<string>", line 1, in <fragment>
builtins.TypeError: exceptions must derive from BaseException

0 个答案:

没有答案