new_array = np.zeros((5,4))
for i in range(3):
new_array[i] = np.array([0.25]*4)
运行结果:
>>> new_array
array([[0.25, 0.25, 0.25, 0.25],
[0.25, 0.25, 0.25, 0.25],
[0.25, 0.25, 0.25, 0.25],
[0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. ]])
new_array = np.zeros((5,4))
for i in range(3):
new_array[i] = np.array([0.25]*4)
运行结果:
>>> new_array
array([[0.25, 0.25, 0.25, 0.25],
[0.25, 0.25, 0.25, 0.25],
[0.25, 0.25, 0.25, 0.25],
[0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. ]])