📜  如何访问索引 numpy 的行和列 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:02.953000             🧑  作者: Mango

代码示例1
>>> a[[0,1,3], :]            # Returns the rows you want
array([[ 0,  1,  2,  3],
       [ 4,  5,  6,  7],
       [12, 13, 14, 15]])
>>> a[[0,1,3], :][:, [0,2]]  # Selects the columns you want as well
array([[ 0,  2],
       [ 4,  6],
       [12, 14]])