如何获取 numpy 数组中元素的索引?

How to get an index for an element in numpy array?

如果我有:

a = np.array(['A','B','C','D'])

如何获取字母 'C' 的索引?

np.where 将找到所有位置:

> np.where(a == 'C')[0][0]
2