Python中怎样使用shape计算矩阵的行和列

如题所述

import numpy
a = numpy.array([[1,2,3],[4,5,6]])
print a.shape

矩阵有一个shape属性,是一个(行,列)形式的元组

温馨提示:答案为网友推荐,仅供参考
第1个回答  2017-12-21
import numpy
a = numpy.array([[00,01,02],
                 [10,11,12]])
print a.shape
print a.shape[0]
print a.shape[1]
---------------------------
输出:
(2,3)  #行数,列数组成的二元组
2
3

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网