】使用花式索引找出大小为(6,6)的二维数组arr1中主对角线上的元素,并赋值给一维数组result,最后打印result。 提示:这一道编程题,需要完整的编程代码 arr1 = np.array([[66, 84, 97, 85, 60, 78], [71, 93, 63, 63, 88, 75], [86, 86, 86, 71, 67, 85], [74, 74, 76, 66, 64, 95], [73, 80, 89, 88, 76, 62], [58, 63, 76, 72, 64, 61]]) 提示:引用包
时间: 2023-05-13 22:05:25 浏览: 57
import numpy as np
arr1 = np.array([[66, 84, 97, 85, 60, 78],
[71, 93, 63, 63, 88, 75],
[86, 86, 86, 71, 67, 85],
[74, 74, 76, 66, 64, 95],
[73, 80, 89, 88, 76, 62],
[58, 63, 76, 72, 64, 61]])
result = arr1[[i for i in range(6)], [i for i in range(6)]]
print(result)
阅读全文