Python中的数组格式
import numpy as np
-
len()
#返回对象的第一维长度 a = [1,2,3] len(a) #output:3 len([a,a]) #output:2 len(np.array(a)) #output:3
-
shape()
#返回ndarray对象每维度的大小 #numpy模块的函数 a = np.array(([1,2,3],[1,2,3]),dtype = np.int8) np.shape(a) #output:(2,3) #shape也是ndarray对象的属性 a.shape #output:(2,3)
-
size()
#返回ndarray对象元素的总个数 #numpy模块的函数 a = np.array(([1,2,3],[1,2,3]),dtype = np.int8) np.size(a) #output:6 #size也是ndarray对象的属性 a.size #output:6
-
count()
#返回list中包含元素的个数 a = [1,2,3,3] a.count(3) #output:3