a = np.arange(6) a = a.reshape((2, 3)) print np.lib.pad(a, 1, 'symmetric')
运行结果:
[[0 0 1 2 2] [0 0 1 2 2] [3 3 4 5 5] [3 3 4 5 5]]