我直接复制的文章里的代码,就是改了个参数名:
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()
为啥。、。。。
Sign in to make a reply
闫佩嘉刷微博
我直接复制的文章里的代码,就是改了个参数名:
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()
为啥。、。。。