用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. Redis数据结构的多种用法

    分布式锁(string) setnx key value,当key不存在时,将 key 的值设为 value ,返回1.若给定的 key 已经存在,则setnx不做任何动作,返回0. 当setnx返回 ...

  2. 机器人编程挑战python

    机器人编程挑战 要使用pip安装模拟器,请运行pip install zombiedice(在Windows上)或pip3 install zombiedice(在macOS和Linux上).要使用一 ...

  3. vue bus 的使用

    简单的状态管理,可以用vue bus vue bus可以实现不同组件间.不同页面间的通信,比如我在A页面出发点击事件,要B页面发生变化,使用方法如下: 全局定义:main.js window.even ...

  4. poj3252(组合数)

    题目链接:http://poj.org/problem?id=3252 题意:给定s.e,求[s,e]之间的Round Number的个数,RN数为二进制表示中0的个数大于1的个数的数,s.e< ...

  5. e-olymp Problem9 N-digit numbers(打表)

    传送门:点我 N-digit numbers Find the quantity of N-digit numbers, which the sum is equal to their product ...

  6. ssh免密登陆权限问题

    问题: 添加了authorized_keys还是不能免密登陆. 思路: 检查端口是否开放,是否允许root用户登录,尝试重启ssh服务... 最有可能的还是权限问题,出现Permission deni ...

  7. 浅析java修饰符之public default protected private static final abstract

    浅析java修饰符之public default protected private static final abstract 一   修饰符的作用:用来定义类.方法或者变量,通常放在语句的最前端 ...

  8. GridView和DataFormatString 日期格式 精确小数点后位数

    如果DataFormatString无效,请添加属性 HtmlEncode = "false" --------------------------------------- Da ...

  9. java_2变量和运算符

    1.变量 存储数据的容器. 2.变量创建的3要素 数据类型 变量名 = 变量值: 如int  a = 10; 3.数据类型的自动转化 当小范围变量向大范围变量转化的时候,会发生这种情况.如int类型变 ...

  10. Echart实现多个y轴,坐标轴的个数及名称由后台传过来的json数据决定。

    yAxis: function(){ var yAxis=[]; for(var i=0;i<legend1.length;i++){ var item={ name:legend1[i], t ...