範圍是20,所以我不確定這個錯誤來自哪裏。添加打印列表長度Ctypes,IndexError:列表索引超出範圍
錯誤在第二行。我如何調用代碼:
plist = StreamingParameterList()
print(len(plist))
plist = [plist[x] for x in [2,4,12,13,14]]
打印長度顯示159
StreamingParameterList()內容
def StreamingParameterList():
""" returns a list of all available streaming parameter names """
num, length = get_parameter_list_size()
splist = []
for id in range(num):
splist.append(get_parameter_list_item(id, length)[0])
return splist
確切的錯誤:
Traceback (most recent call last):
File "testStream.py", line 27, in (module)
plist = [plist[x] for x in [2,4,12,13,14]]
File "testStream.py", line 27, in (listcomp)
plist = [plist[x] for x in [2,4,12,13,14]]
IndexError: list index out of range
如果你在'plist = StreamingParameterList()'後面'打印(len(plist))',它說什麼? – Kevin
你說「範圍是20」,但我沒有看到你在你的代碼中驗證的證據。 –