np.zeros函数知识大全(numpy.zeros())

版权声明:创作不易,转载请留出处。 https://blog.csdn.net/qq_39072607/article/details/89321495

np.zeros函数知识大全

np.zeros函数的作用

返回来一个给定形状和类型的用0填充的数组;
zeros(shape, dtype=float, order=‘C’)
shape:形状
dtype:数据类型,可选参数,默认numpy.float64
order:可选参数,c代表与c语言类似,行优先;F代表列优先

import numpy as np

print(np.zeros((2,5)))

结果为一个2行5列的矩阵
[[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]]

print(np.zeros((2,5),dtype= np.int))

结果为
[[0 0 0 0 0]
[0 0 0 0 0]]

猜你喜欢

转载自blog.csdn.net/qq_39072607/article/details/89321495
今日推荐