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:
np.zeros(5) Out[1]: array([ 0., 0., 0., 0., 0.])
np.zeros((4,),dtype = int) Out[2]: array([0, 0, 0, 0])
np.zeros((2,3)) Out[2]: array([[ 0., 0., 0.], [ 0., 0., 0.]])
s = (3,3) np.zeros(s) Out[3]: array([[ 0., 0., 0.], [ 0., 0., 0.], [ 0., 0., 0.]])
np.zeros((2,),dtype = [('x','i4'),('y','i4')]) Out[4]: array([(0, 0), (0, 0)], dtype=[('x', '
np.zeros((3,),dtype = [('x','i4'),('y','i4')]) Out[5]: array([(0, 0), (0, 0), (0, 0)], dtype=[('x', '
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/224612.html原文链接:https://javaforall.net
