📜  python如何复制二维数组,省略最后一列 - Python代码示例

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

代码示例1
In [1]: import numpy as np

In [2]: H = np.meshgrid(np.arange(5), np.arange(5))[0]

In [3]: H
Out[3]: 
array([[0, 1, 2, 3, 4],
       [0, 1, 2, 3, 4],
       [0, 1, 2, 3, 4],
       [0, 1, 2, 3, 4],
       [0, 1, 2, 3, 4]])

In [4]: Hsub = H[1:-1,1:-1]

In [5]: Hsub
Out[5]: 
array([[1, 2, 3],
       [1, 2, 3],
       [1, 2, 3]])