Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
318 views
in Technique[技术] by (71.8m points)

python - 块数组尺寸(Numpy array dimensions)

I'm currently trying to learn Numpy and Python.

(我目前正在尝试学习Numpy和Python。)

Given the following array:

(给定以下数组:)

import numpy as np
a = np.array([[1,2],[1,2]])

Is there a function that returns the dimensions of a (ega is a 2 by 2 array)?

(是否有一个返回的尺寸的函数a (EGA是一个2×2阵列)?)

size() returns 4 and that doesn't help very much.

(size()返回4,这并没有太大帮助。)

  ask by morgan freeman translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It is .shape :

(它是.shape :)

ndarray.

(ndarray。)

shape

(形状)
Tuple of array dimensions.

(数组维度的元组。)

Thus:

(从而:)

>>> a.shape
(2, 2)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...