numpy.empty_like(a,dtype = None,order ='K',subok = True):返回形狀和類型與給定數組相同的新數組。
參數:
shape : Number of rows order : C_contiguous or F_contiguous dtype : [optional, float(by Default)] Data type of returned array. subok : [bool, optional] to make subclass of a or not
返回:
array with the same shape and type as a given array.
# Python Program illustrating
# numpy.empty_like method
import numpy as geek
a = geek.empty_like([2, 2], dtype = int)
print("\nMatrix a : \n", a)
c = a = ([1,2,3], [4,5,6])
print("\nMatrix c : \n", geek.empty_like(c))
輸出:
Matrix a : [ 16843008 1058682594] Matrix c : [[0 0 0] [0 0 0]]
注意:
這些代碼無法在online-ID上運行。請在您的係統上運行它們以探索其工作原理。
相關用法
注:本文由純淨天空篩選整理自 numpy.empty_like() in Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。