numpy.zeros(shape,dtype=float,order = ‘C’)
返回给定形状和类型的新数组,用 0 填充。
| 参数: |
shape:int 或 int 的元组
|
| | 新阵列的形状,例如:(2,3)或 2。 |
| | dtype:数据类型,可选 |
| | 数组的所需数据类型,例如 numpy.int8。默认是 numpy.float64 |
| | order:{‘C’,’F’},可选,默认:’C’ |
| | 是否在内容中以行(C)或列(F)顺序存储多维数据。 |
| 返回: | out:ndarray |
| | 具有给定形状,类型和顺序的 0 的数组。 |
Example:
Out[1]: array([ 0., 0., 0., 0., 0.])
np.zeros((4,),dtype = int)Out[2]: array([0, 0, 0, 0])
np.zeros((2,),dtype = [('x','i4'),('y','i4')]) dtype=[('x', '<i4'), ('y', '<i4')])
np.zeros((3,),dtype = [('x','i4'),('y','i4')])array([(0, 0), (0, 0), (0, 0)], dtype=[('x', '<i4'), ('y', '<i4')])