try:
a,b=map(float,input().split())
c=a/b
except ZeroDivisionError:
print('分母不能为0')
except TypeError:
print('数值类型错误')
except NameError:
print('变量名错误')
except ValueError:
print('数值错误')
else:
print('没有错误')
print('a/b=',c)
觉得有用的话采纳一下哈
# 异常
try:
print(1/0)
except ZeroDivisionError:
print("You can't divide by zero!" )
# 类型判断用 isinstance