函数返回数据类型错误TypeError: bad operand type

def my_abs(x):
if not isinstance(x, (int, float)):
raise TypeError(‘bad operand type’)
if x >= 0:
return x
else:
return -x
my_abs(‘a’)

猜你喜欢

转载自blog.csdn.net/weixin_40974880/article/details/89087844