Python numpy.unravel_index()函数
numpy.unravel_index()函数将一个平面索引或平面索引阵列转换为一个坐标阵列的元组。
语法: numpy.unravel_index(indices, shape, order = ‘C’)
参数 :
indices : [array_like] 一个整数数组,其元素是维度形状的数组的扁平化版本的索引。
shape : [tuple of ints] 阵列的形状,用于解开索引。
order : [{‘C’, ‘F’}, optional] 决定多指标是否应被视为以行为主(C-style)或列为主(Fortran-style)的顺序进行索引。
返回 : [tuple of ndarray] tuple中的每个数组都有与索引数组相同的形状。
代码#1:
输出 :
代码#2:
输出 :