使用 Python 以数组索引表示的列表元素
python 434
原文标题 :Elements of list in terms of array indices using Python
如何根据A
的数组索引编写列表B
的元素?附加了所需的输出。
import numpy as np
A = np.array([[1,2,3],[4,5,6],[7,8,9]])
B = [1,5,6]
所需的输出是
B=[A[0,0], A[1,1], A[1,2]]