numpy.matlib.zeros()函数返回给定形状和类型的矩阵,并用零填充。
用法: numpy.matlib.zeros(shape, dtype = None, order = ‘C’)
参数:
shape :[sequence of ints] Shape of the empty matrix.
dtype :[data-type, optional] The desired data-type for the matrix, default is float.
order :[{‘C’, ‘F’}, optional] Whether to store the result in C- or Fortran-contiguous order, default is ‘C’.
Return :[matrix] Zero matrix of given shape, dtype, and order.
代码1:
# Python program explaining
# numpy.matlib.zeros() function
# importing numpy as geek
# and importing matlib module
import numpy as geek
import numpy.matlib
gfg = geek.matlib.zeros((3, 3))
print (gfg)
输出:
[[ 0. 0. 0.] [ 0. 0. 0.] [ 0. 0. 0.]]
代码2:
# Python program explaining
# numpy.matlib.zeros() function
# importing numpy as geek
# and importing matlib module
import numpy as geek
import numpy.matlib
gfg = geek.matlib.zeros(4)
print (gfg)
输出:
[[ 0. 0. 0. 0.]]
相关用法
- Python Wand function()用法及代码示例
- Python map()用法及代码示例
- Python hex()用法及代码示例
- Python dir()用法及代码示例
- Python sum()用法及代码示例
- Python ord()用法及代码示例
- Python id()用法及代码示例
- Python now()用法及代码示例
- Python cmp()用法及代码示例
- Python int()用法及代码示例
- Python tell()用法及代码示例
- Python str()用法及代码示例
- Python oct()用法及代码示例
- Python property()用法及代码示例
- Python Wand fx()用法及代码示例
- Python math.cos()用法及代码示例
注:本文由纯净天空筛选整理自sanjoy_62大神的英文原创作品 numpy.matlib.zeros() function | Python。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。