这个列表类似于这样:
[["12", "stuA", "stuB"], ["51", "stuC", "stuD"], ..., ["3234", "moreStuff", "andMore"]]
现在我需要仅通过它的第一个值(例如"332"
)来定位一个项目(获取索引)。除了从第一个开始迭代以与每个值进行比较,还有其他更好的方法吗?
代码:
index = 0
for item in thelist:
if item[0] == "332":
print index
index = index + 1