let itemList = document.getElementsByClassName('sky-item') // 一行所有元素 let index = 0 for(let i = 0; i<itemList.length; i++){ // 寻找当前元素 if("sky-item focused" == itemList.item(i).className) index = i }…
var arr=["a","b","c","d","c","b","d","f"];var newarr=[];//存放不重复元素的数组var count=[];//记录重复元素的元素和索引值for(var i=0;i<arr.length;i++){ var type=true; for(var j=0;j<newarr.length…
list = [1,2,3,3,2,1] list.index(1) # 只能获得首个1的索引值 如果要获得所有该元素的索引值 import numpy as np arr = np.array(list) index = np.where(arr==1) index[0] 然后才能用 for i in index[0]: print(i)…