Discuss / Python / 复制的文章里的代码 为什么还是无法正确报错

复制的文章里的代码 为什么还是无法正确报错

Topic source

我直接复制的文章里的代码,就是改了个参数名:

def eee(x): if not isinstance(x, (int, float)): raise TypeError('bad operand type') if x >= 0: return x else: return -x

可结果当我输入eee('a') 的时候 报错还是 TypeError: unorderable types: str() >= int()

为啥。、。。。


  • 1

Reply