3 回答

TA貢獻(xiàn)1875條經(jīng)驗(yàn) 獲得超5個(gè)贊
array
item
itemindex = numpy.where(array==item)
array[itemindex[0][0]][itemindex[1][0]]
array[itemindex[0][1]][itemindex[1][1]]

TA貢獻(xiàn)1719條經(jīng)驗(yàn) 獲得超6個(gè)贊
nonzero
where
>>> t = array([1, 1, 1, 2, 2, 3, 8, 3, 8, 8])>>> nonzero(t == 8)(array([6, 8, 9]),)>>> nonzero(t == 8)[0][0]6
>>> nonzero(r_[1, diff(t)[:-1]])(array([0, 3, 5, 6, 7, 8]),)
[1, 1, 1, 2, 2, 3, 8, 3, 8, 8]
t
>>> st = sorted(t)>>> nonzero(r_[1, diff(st)[:-1]])(array([0, 3, 5, 7]),)

TA貢獻(xiàn)1860條經(jīng)驗(yàn) 獲得超9個(gè)贊
l = [1,2,3,4,5] # Python lista = numpy.array(l) # NumPy arrayi = a.tolist().index(2) # i will return index of 2print i
添加回答
舉報(bào)