#运行错误IndexError : list index out of range# 错误原因及解决办法

  在读取txt文件时遇到IndexError: list index out of range
如下图:

   加入如下代码,检查原因:
 
 
   
已经知道rows一共有20662行,往下翻结果,还是报错了:
 

  意味着在读取rows的第9411行时出错了,这意味在9411可能存在list[index]的index超出范围,或者出现list[0]的原因。

  因此只要跳过index超出范围,或者出现list[0]的那一行就能解决该问题,代码如下:

 问题解决。(具体为什么会出现这种请款单原因不知)

猜你喜欢

转载自www.cnblogs.com/maybe-lucky/p/12741407.html