本人在讀取txt文件時遇到IndexError: list index out of range
如下圖:
於是檢查錯誤原因,加入如下代碼:
以指導rows一共有20662行,往下翻結果,還是報錯了:
意味着在讀取rows的第9411行時出錯了,這意味在9411可能存在list[index]的index超出範圍,或者出現list[0]的原因。
因此只要跳過index超出範圍,或者出現list[0]的那一行就能解決該問題,代碼如下:
Done!
本人在讀取txt文件時遇到IndexError: list index out of range
如下圖:
於是檢查錯誤原因,加入如下代碼:
以指導rows一共有20662行,往下翻結果,還是報錯了:
意味着在讀取rows的第9411行時出錯了,這意味在9411可能存在list[index]的index超出範圍,或者出現list[0]的原因。
因此只要跳過index超出範圍,或者出現list[0]的那一行就能解決該問題,代碼如下:
Done!
class MetaCls(type): def __new__(cls, *args, **kwargs): print("in MetaCls") # return super(Meta