The exception is right there. It's an index error, that is it's trying to do something going beyond the range of what this thing could deal with.
但他事实上抛出一个异常,异常就在这里,这是一个下标错误,它是试图去取超出范围的元素造成的。
But if I say turn this into a float, ah it throws a value error exception.
它就会抛出一个值错误异常了,它会告诉我输入了一种错误的值。
So it's not defined. But in fact, what this did was it threw an exception.
这是未定义,但实际上,这里做的就是抛出一个异常。
The format is the same. I'm going to ask for some input, and then I am going to use that procedure to check, is this the right type of value. And I'm trying to use that to do the coercion if you like. Same thing if it works, I'm going to skip that, if it not, it's going to throw the exception.
格式是一样的,我需要一些输入,然后我要用一个过程来检查,是否是正确的值,然后你就可以做强制转换了,如果能运行,那是一样的,我打算跳过这段,如果不正确,那就会抛出一个异常。
应用推荐