Python中的索引超出范围

时间:2015-01-19 08:22:55

标签: python

以下是代码

infile = ['02000YBSD', 'GBP', '20140930', '1.66928', '1', '1']
for line in infile:
    a = line.split()
    fdmAPI.logInfo(str(a))
    CheckNumeric = a[4]
    fdmAPI.logInfo(CheckNumeric[1])

1 个答案:

答案 0 :(得分:0)

您尝试访问长度小于4的数组的4个元素:

>>> line = '1'
>>> a = line.split()
>>> print a, len(a)
['1'] 1
>>> CheckNumeric = a[4]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: list index out of range