当前位置:   article > 正文

python中shape[0]与shape[1]

shape[0]
import numpy as np
k = np.matrix([[1, 2, 3, 4],
             [5, 6, 7, 8],
             [9, 10, 11, 12]])
print(np.shape(k))       # 输出(3,4)表示矩阵为3行4列
print(k.shape[0])        # shape[0]输出3,为矩阵的行数
print(k.shape[1])        # 同理shape[1]输出列数
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
'
运行
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/816912
推荐阅读
相关标签
  

闽ICP备14008679号