Python Padding

B=np.pad(A,((1,2),(3,4)),'constant',constant_values = (0,0))
A = np.arange(1,5).reshape(2,2)
print(A)
[[1 2]
 [3 4]]
B=np.pad(A,((1,2),(3,4)),'constant',constant_values = (0,0))
print(B)
[[0 0 0 0 0 0 0 0 0]
 [0 0 0 1 2 0 0 0 0]
 [0 0 0 3 4 0 0 0 0]
 [0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0]]

你可能感兴趣的:(python,开发语言)