索引错误:列表索引超出范围(Python)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16005707/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Index Error: list index out of range (Python)
提问by user2280738
I am a beginner programmer and im not sure what this means...
我是一名初级程序员,我不确定这意味着什么......
Index Error: list index out of range
索引错误:列表索引超出范围
回答by phoebus
Generally it means that you are providing an index for which a list element does not exist.
通常,这意味着您提供的索引不存在列表元素。
E.g, if your list was [1, 3, 5, 7], and you asked for the element at index 10, you would be well out of bounds and receive an error, as only elements 0 through 3 exist.
例如,如果您的列表是[1, 3, 5, 7],并且您要求索引 10 处的元素,那么您将完全超出范围并收到错误消息,因为只有元素 0 到 3 存在。

