np.zeros()
点击查看代码
# np.zeros()
# 返回来一个给定形状和类型的用0填充的数组;
# zeros(shape, dtype=float, order=‘C’)
# shape:形状
# dtype:数据类型,可选参数,默认numpy.float64
# order:可选参数,C:行优先;F:代表列优先
import numpy as np
a1 = np.zeros((2, 5))
# print(a1)
# output
# [[0. 0. 0. 0. 0.]
# [0. 0. 0. 0. 0.]]
a2 = np.zeros((2, 5), dtype=int)
print(a2)
# output
# [[0 0 0 0 0]
# [0 0 0 0 0]]