numpy的数组维 [英] Numpy array dimensions
本文介绍了numpy的数组维的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
目前,我正在努力学习numpy的和Python。鉴于以下数组:
I'm currently trying to learn Numpy and Python. Given the following array:
import numpy as N
a = N.array([[1,2],[1,2]])
是否有返回的尺寸(e.g.a是2×2的数组)的函数。
Is there a function that returns the dimensions of a (e.g.a is a 2 by 2 array).
尺寸()
返回4,它帮助不大。
size()
returns 4 and that doesn't help very much.
推荐答案
是<一个href=\"http://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.shape.html#numpy.ndarray.shape\"><$c$c>.shape$c$c>:
ndarray。形状结果
数组维度的元组。
ndarray.shape
Tuple of array dimensions.
因此:
>>> a.shape
(2, 2)
这篇关于numpy的数组维的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文