numpy.shape()函数
点击查看代码
import numpy as np
a = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]])
print(a.shape[0]) # 读取行数 4
print(a.shape[1]) # 读取列数 3
print(a.shape) # 读取行、列数 (4,3)
import numpy as np
a = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]])
print(a.shape[0]) # 读取行数 4
print(a.shape[1]) # 读取列数 3
print(a.shape) # 读取行、列数 (4,3)