📅  最后修改于: 2022-03-11 14:46:36.331000             🧑  作者: Mango
import numpy as np
# https://numpy.org/doc/stable/reference/generated/numpy.pad.html
image = np.ones((2,2), dtype=int)
padded_image = np.pad(image, 1, dtype=int, mode='constant')
print(padded_image)
# [[0 0 0 0]
# [0 1 1 0]
# [0 1 1 0]
# [0 0 0 0]]