Numpy: 数组属性

来自CloudWiki
跳转至: 导航搜索

数组属性

>>> import numpy as np
>>> a = np.ones((4,5))
>>> print(a)
[[1. 1. 1. 1. 1.]
 [1. 1. 1. 1. 1.]
 [1. 1. 1. 1. 1.]
 [1. 1. 1. 1. 1.]]
>>> a.ndim
2
>>> a.shape
(4, 5)
>>> a.dtype
dtype('float64')