在Python中三行获取指定元素在列表中出现的全部位置的下标

lst = [114, 514, 19, 19, 114, 123, 114, 12342354235]
toFind = 114
print(list(filter(lambda x: lst[x]==toFind, list(range(len(lst))))))

如代码,利用list(range(len(lst)))创建下标列表,再利用filter函数筛选出所有满足条件的下标。

posted @ 2020-11-28 20:57  wr786  阅读(1190)  评论(0编辑  收藏  举报