爬虫时出现 IndexError: list index out of range 的原因有两种:
简单举例如下:
第一种情况: index越界
Alex = [1,2,3]
Alex[1]
2
Alex[0]
1
Alex[2]
3
Alex[3]
Traceback (most recent call last):
File "<input>", line 1, in <module>
IndexError: list index out of range
第二种情况:列表为空
Eric = []
Eric[1]
Traceback (most recent call last):
File "<input>", line 1, in <module>
IndexError: list index out of range