在python中我们可以使用
map(lambda word: someFunction(element), data)
但是我可以通过访问索引来判断正在访问哪个元素吗?
map(lambda word: someFunction(word,indexOfcurrentelement), data)
最佳答案
如果你先枚举就可以。
map(lambda (index, word): someFunction(word, index), enumerate(data))
关于python:我可以在使用 map() 时访问元素的索引吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5775144/