今天写个ping vpn的python脚本,报错IndexError: list index out of range 最后查看是python读取文件中出现空格 去掉空格即可…
用python写脚本查询字典时,在遍历字典时循环到某一项时老是报错   出现这种错误有两种情况: 第1种可能情况 list[index]index超出范围 第2种可能情况 list是空值就会出现 IndexError: list index out of range 第二种情况尤为难以排除错误…
pyinstaller将py打包为exe文件,用pysintaller居然报错 File "c:\anaconda3\lib\site-packages\PyInstaller\depend\utils.py", line 226, in __scan_code_instruction_for_ctypes name = co.co_names[oparg] IndexError: tuple index out of range 1 2 3 搜索了一番,用群众神奇的方式 找到D:\p…
IndexError:string index out of range 出现在下标越界的情况,如 item[1],可能为空的时候下标就会越界…
今天第一次发随笔还有许多不足之处,欢迎评论!!! 最近在写一个成语接龙的小游戏,结果在数组添加元素时报错:IndexError: list index out of range 源码: import pypinyin robot=[""] #机器回答的成语列表(先不加成语) robotpy1=[] #机器回答成语列表的所有成语的第一个拼音 for k in robot:#便利 robotpy1.append(pypinyin.pinyin(k, style=pypinyin.NORMA…
使用mac安装MySQLdb的时候出现string index out of range 大概的错误是这样的: 然后尝试手动安装,我下载了包后,依然出现这个错误. 于是百度了下: https://www.jianshu.com/p/da9dd5dd4bd2 这个匹配度是最高的,但是这个兄弟居然半路放弃了(没有转载哈).... 后来我就google了下, 原贴地址:https://stackoverflow.com/questions/51123044/pip-install-mysql-pyth…
引用超过list最大索引,此错误非常常见,注意列表的元素个数 ----------------------------------------------…
生成随机密码#!/usr/bin/env python import stringfrom random import choice def gen_pass(num=9): all_chs = string.letters + string.digits pwd = '' for i in range(9): pwd += choice(all_chs) return pwd if __name__ == '__main__': print gen_pass (4) print gen_pas…
TypeError: 'module' object is not callable 模块未正确导入,层级关系没找对 缩进错误. IndentationError: unindent does not match any outer indentation level 缩进错误.没有对齐 解决办法: 1.极有可能是空格和tab键混搭使用了,视图-显示符号-显示空格与制表符 引包错误 自己写的py文件不要与第三方库重名 编码错误 1.程序本身有编码,一般在程序的头部声明 2.使用的IDE有编码,除…
最近刚刚接触Python,为了养成好习惯,遇到了诸多的问题,林林总总,在这里简单记录下: 编写简单的python语句时: module level import not at top of file         解决:import不在文件的最上面,可能引用之前还有代码,把import引用放到文件的最上部就可以消除警告了.若果import失败,则库内不存在相关文件,需要进行下载安装 expected 2 blank lines,found 0         解决:期望上面有2个空白行,发现0…