array shape输出数组的行列

来源:互联网 发布:广电局禁止网络机顶盒 编辑:程序博客网 时间:2024/06/11 06:37
import numpy as np
= np.array([[1,2,5],[2,3,5],[3,4,5],[2,3,6]])
# 输出数组的行和列数
print x.shape  # (4, 3)
# 只输出行数
print x.shape[0# 4
# 只输出列数
print x.shape[1# 3