IndexError(索引错误):常见于 Python 等编程语言的运行时异常,表示你用下标/索引访问序列(如列表、元组、字符串)时,索引超出了有效范围(例如列表长度为 3,却访问 a[3])。
/ˈɪndɛks ˌɛrər/
I got an IndexError when I tried to access the fourth item in a three-item list.
当我试图访问只有三个元素的列表中的第四个元素时,出现了 IndexError。
If you loop past the end of the array without checking the length, your program may raise an IndexError and stop unexpectedly.
如果你在循环中不检查长度而越过数组末尾,程序可能会抛出 IndexError 并意外停止。
由 index(索引、下标,来自拉丁语 index,意为“指示者/目录”)与 error(错误,源自拉丁语 error,“偏离/误差”)组合而成。在编程语境中,表示“与索引相关的错误”。