📜  Python中的 numpy.full()

📅  最后修改于: 2022-05-13 01:55:05.236000             🧑  作者: Mango

Python中的 numpy.full()

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

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]]