当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python numpy.full()用法及代码示例


numpy.full(shape,fill_value,dtype = None,order ='C'):返回形状和类型与填充fill_value的给定数组相同的新数组。
参数:

shape      : Number of rows
order      : C_contiguous or F_contiguous
dtype      : [optional, float(by Default)] Data type of returned array.  
fill_value : [bool, optional] Value to fill in the array.

返回值:

ndarray
# Python Programming illustrating 
# numpy.full method 
  
import numpy as geek 
  
a = geek.full([2, 2], 67, dtype = int) 
print("\nMatrix a : \n", a) 
  
c = geek.full([3, 3], 10.1) 
print("\nMatrix c : \n", c)

输出:



Matrix a : 
 [[67 67]
 [67 67]]

Matrix c : 
 [[ 10.1  10.1  10.1]
 [ 10.1  10.1  10.1]
 [ 10.1  10.1  10.1]]


相关用法


注:本文由纯净天空筛选整理自 numpy.full() in Python。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。