在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函數篩選出全部知足條件的下標。python

相關文章
相關標籤/搜索