我想創建一個2D列表,我不斷得到相同的錯誤「TypeError:列表索引必須是整數,而不是元組」我不明白爲什麼,或者如何正確使用2D列表。2d列表不能正常工作
Total = 0
server = xmlrpclib.Server(url);
mainview = server.download_list("", "main")
info = [[]]
info[0,0] = hostname
info[0,1] = time
info[0,2] = complete
info[0,3] = Errors
for t in mainview:
Total += 1
print server.d.get_hash(t)
info[Total, 0] = server.d.get_hash(t)
info[Total, 1] = server.d.get_name(t)
info[Total, 2] = server.d.complete(t)
info[Total, 3] = server.d.message(t)
if server.d.complete(t) == 1:
Complete += 1
else:
Incomplete += 1
if (str(server.d.message(t)).__len__() >= 3):
Error += 1
info[0,2] = Complete
info[0,3] = Error
一切正常,除了試圖處理信息。
Python中沒有這樣的「2d列表」。你有什麼是一個列表,其內容也列表。如果你想想這是什麼意思,你會明白爲什麼這不起作用。 – BrenBarn