【发布时间】:2018-07-01 21:40:37
【问题描述】:
我试图找到 v 的索引,但它总是给我:'numpy.ndarray' object has no attribute 'index'
我试过了:
TypeError: slice indices must be integers or None or have an __index__ method. How to resolve it?
How to find the index of an array within an array.
Finding the index of an item given a list containing it in Python
他们都没有回答我的问题
v = np.random.randn(10)
print(v)
maximum = np.max(v)
minimum = np.min(v)
print(maximum, minimum)
v.index(maximum, minimum)
编辑:哦,废话,我把 ma 而不是最大的坏。那时我才开始编程。
【问题讨论】:
-
ma和mi是什么? -
你说
index是什么意思?? -
看起来你在找
np.where() -
@Likedapro 看我的回答
-
index是一个列表方法。v是一个 numpy 数组。有区别。