如何获取列表中每个项(包括重复项)的索引?据我所知列表.索引只会给我一个重复项的第一个索引,像这样。你知道吗
registros = ["Celda", "Celda", "Test", "Celda", "Celda", "Celda"]
for item in registros:
index_found = registros.index(item)
print(str(index_found) + " " + dato)
输出:
0 Celda
0 Celda
2 Test
0 Celda
0 Celda
0 Celda
那么,我该如何(尽可能简单地)获得所需的输出呢?地址:
0 Celda
1 Celda
2 Test
3 Celda
4 Celda
5 Celda
目前没有回答
相关问题 更多 >
编程相关推荐