我想创建一个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