【发布时间】:2022-01-25 17:23:36
【问题描述】:
我遇到了一个有趣的问题:
我们以这样一个函数为例:
def SumNumbers(a,b,c,d,e,f):
try:
print("Marta: ",
a,"+",b,'+',c,'+',d,'+',e,'+',f,
'=',
a + b + c + d + e + f)
except TypeError:
print("Enter the values for the 6 parameters of the program")
在这种情况下我们如何处理这个错误:
SumNumbers(1,2,3)
在这种情况下:
SumNumbers(1,2,3,4,5,5,6,77,7,8,88,8,8,8,8)
当然,我的意思是在函数体中处理这个错误:)
不幸的是,我拦截 TypeError 的尝试无效:(
【问题讨论】:
标签: python exception typeerror