用python写脚本查询字典时,在遍历字典时循环到某一项时老是报错

 

出现这种错误有两种情况:

第1种可能情况

list[index]index超出范围

第2种可能情况
list是空值就会出现

IndexError: list index out of range

第二种情况尤为难以排除错误

Python常见错误:IndexError: list index out of range的更多相关文章

  1. python报错IndexError: list index out of range

    今天写个ping vpn的python脚本,报错IndexError: list index out of range 最后查看是python读取文件中出现空格 去掉空格即可

  2. pyinstaller 将.py生成.exe ----报错 “IndexError: tuple index out of range”

    pyinstaller将py打包为exe文件,用pysintaller居然报错 File "c:\anaconda3\lib\site-packages\PyInstaller\depend ...

  3. IndexError:string index out of range

    IndexError:string index out of range 出现在下标越界的情况,如 item[1],可能为空的时候下标就会越界

  4. 在数组添加元素时报错:IndexError: list index out of range

    今天第一次发随笔还有许多不足之处,欢迎评论!!! 最近在写一个成语接龙的小游戏,结果在数组添加元素时报错:IndexError: list index out of range 源码: import ...

  5. mac安装MySQLdb:IndexError: string index out of range

    使用mac安装MySQLdb的时候出现string index out of range 大概的错误是这样的: 然后尝试手动安装,我下载了包后,依然出现这个错误. 于是百度了下: https://ww ...

  6. IndexError: list index out of range Python常见错误

    引用超过list最大索引,此错误非常常见,注意列表的元素个数 ----------------------------------------------

  7. python 常见错误和异常 函数 正则表达式及多线程编程

    生成随机密码#!/usr/bin/env python import stringfrom random import choice def gen_pass(num=9): all_chs = st ...

  8. python常见错误总结

    TypeError: 'module' object is not callable 模块未正确导入,层级关系没找对 缩进错误. IndentationError: unindent does not ...

  9. python常见错误

    最近刚刚接触Python,为了养成好习惯,遇到了诸多的问题,林林总总,在这里简单记录下: 编写简单的python语句时: module level import not at top of file ...

随机推荐

  1. tab template

    <div class="box"> <div class="box-body"> <div class="nav-tab ...

  2. AJAX模板

    $.ajax({ type:"",//Ajax请求的提交方式(GET或POST) dataType:"text",//请求的类型 url:"" ...

  3. 数据存储 共享参数 SharedPreferences

    先要声明文件名和操作方式,第一个参数:文件名为"share.xml",第二个参数:私有模式SharedPreferences shared = getSharedPreferenc ...

  4. JS函数入门

    一. 函数的声明及调用 * 1函数的格式:function 函数名(参数1,参数2......){ * //函数体 * return 结果: * * } * 函数调用的格式: * 直接调用:函数名(参 ...

  5. Unity5权威讲解+项目源码+MP4

    扫码时备注或说明中留下邮箱 付款后如未回复请至https://shop135452397.taobao.com/ 联系店主

  6. CSS3实现图片循环旋转

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...

  7. VTP

    VTP VLAN中继协议(Vlan Trunking Protocol),是CISCO专用协议.VTP负责在VTP域内同步VLAN信息,这样就不必在每个交换机上配置相同的VLAN信息.VTP还提供一种 ...

  8. java_13.1 javaAPI

    1 API概念 API:是一些预先定义的函数,目的是提供应用程序与开发人员基于某软件或硬件的以访问一组例程的能力,而又无需访问源码,或理解内部工作机制的细节.2 String类的概念和不变性 Stri ...

  9. AngularJS——第7章 依赖注入

    第7章 依赖注入 AngularJS采用模块化的方式组织代码,将一些通用逻辑封装成一个对象或函数,实现最大程度的复用,这导致了使用者和被使用者之间存在依赖关系. 所谓依赖注入是指在运行时自动查找依赖关 ...

  10. php7下安装event扩展

    有效安排I/O,时间和信号的扩展 使用可用于特定平台的最佳I/O通知机制的事件,是PHP基础设施的libevent端口. 下载地址:http://pecl.php.net/package/event ...