Python 中的 numpy.empty_like()

| |

numpy.empty_like (a, dtype = None, order = ' K ', subok = True): 返回一個與這個形狀和類型相同的新數組
參數:

shape:行數order: C_contiguous or F_contiguous dtype:  [可選,float(默認)] 返回數組的數據類型。 subok:  [bool, optional] 是否是a的子類

返回:

具有相同形狀的數組和類型為給定的數組。 

# Python 程序說明
# numpy.empty_like 方法


import numpy as geek

a = 極客.empty_like ([ 2 , 2 ], dtype = int )

print ( " 矩陣a:" , a)

c = a = ([ 1 , 2 , 3 ], [ 4 , 5 , 6 ])

print ( "矩陣 c:" , geek.empty_like (c))

輸出:

矩陣a:[16843008 1058682594] 矩陣c:[[0 0 0] [0 0 0]] 

注意:
這些代碼不適用於在線 ID。請在您的系統上運行它們,看看它們是如何工作的。

本文由 Mohit Gupta_OMG 提供

Shop

Learn programming in R: courses

$

Best Python online courses for 2022

$

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers


Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method