numpy.unravel

it2023-03-20  84

numpy.unravel_index()函数的用法

用法: numpy.unravel_index(indices, shape, order=‘C’)函数的作用是获取一个/组int类型的索引值在一个多维数组中的位置

**说明:** __indices:是索引值,可以是一个数,也可以是一个列表。__ __shape:代表的是数组的形状。__

举个例子: 构建一个shape为(6,7,8)的矩阵,并找到第100个元素的索引值

import numpy as np np.unravel_index(100,(6,7,8))
最新回复(0)