V2EX  ›  英汉词典

IndexError

释义 Definition

IndexError(索引错误):常见于 Python 等编程语言的运行时异常,表示你用下标/索引访问序列(如列表、元组、字符串)时,索引超出了有效范围(例如列表长度为 3,却访问 a[3])。

发音 Pronunciation (IPA)

/ˈɪndɛks ˌɛrər/

例句 Examples

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 并意外停止。

词源 Etymology

index(索引、下标,来自拉丁语 index,意为“指示者/目录”)与 error(错误,源自拉丁语 error,“偏离/误差”)组合而成。在编程语境中,表示“与索引相关的错误”。

相关词 Related Words

文学与作品 Literary Works

  • Automate the Boring Stuff with Python(Al Sweigart)
  • Python Crash Course(Eric Matthes)
  • Fluent Python(Luciano Ramalho)
  • Learning Python(Mark Lutz)
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   4403 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 12ms · UTC 04:08 · PVG 12:08 · LAX 21:08 · JFK 00:08
♥ Do have faith in what you're doing.