# 多个 except 子句
try:
x = int(input('Enter the first number: '))
y = int(input('Enter the second number: ')) print(x / y)
except ZeroDivisionError:
print("The second number can't be zero!")
except TypeError:
print("That wasn't a number, was it?")
几种Error的整理
格式化字符串处理
TypeError:在提供的参数类型和数量与格式化字符串模板不符合的时候弹出。
ValueError:在格式化字符串本身不符合规范时弹出。