我得到IndexError: list index out of range
并且不明白为什么。我只是在动态列表中添加一个新元素:
order_array = []
for package in names_array:
package = names_array[i]
logInfo("NAME : " + package)
command = vars.sdp_info_command + " -b " + package + " | grep 'Order' | awk --field-separator=: '{print $2}'"
tmp = []
r_code = execute(command, output=tmp)
if r_code != 0:
return 1
order_array.append(tmp[0].strip())
程序在此处失败,但并非总是如此:order_array.append(tmp[0].strip())
。
可能是什么问题?