b = np.argwhere(L == i)返回的是啥
时间: 2023-08-08 21:06:10 浏览: 75
`b = np.argwhere(L == i)` 返回的是一个 Numpy 数组,其中存储了数组 `L` 中所有等于 `i` 的元素的索引。具体来说,如果 `L` 的形状为 `(m, n)`,则 `b` 的形状为 `(k, 2)`,其中 `k` 是等于 `i` 的元素的数量,第一列存储这些元素在 `L` 中的行索引,第二列存储这些元素在 `L` 中的列索引。
相关问题
b = np.argwhere(L == i)
这行代码是在使用 NumPy 库中的 argwhere 函数,根据条件返回输入数组中符合条件的元素的索引值。在这里,输入数组 L 中与 i 相等的元素的索引值被存储在 b 中。具体来说,b 是一个二维数组,每一行表示一个符合条件的元素的索引,第一列为该元素在 L 中的行索引,第二列为该元素在 L 中的列索引。
indexName = np.argwhere(scoreAll==name )
这行代码的意思是在 `scoreAll` 这个二维数组中寻找值为 `name` 的元素,并返回该元素的下标。具体来说,`np.argwhere()` 函数会返回一个包含所有符合条件的元素下标的数组,每个下标都是一维数组。在这个代码中,`scoreAll==name` 会返回一个和 `scoreAll` 同样大小的布尔型数组,其中符合条件的元素对应的值为 `True`,不符合条件的元素对应的值为 `False`。`np.argwhere(scoreAll==name)` 会返回一个包含所有 `True` 的下标的数组,这些下标表示了 `scoreAll` 中值为 `name` 的元素的位置。
阅读全文
相关推荐
















