numpy 矩阵和数组

Posted zhhy236400

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了numpy 矩阵和数组相关的知识,希望对你有一定的参考价值。

矩阵只能是二维的,数组可以任意维度。

对于矩阵:

from numpy import *
a=mat([[1],[2],[2]])
print(a[0])

 输出:

[[1]]

 对于数组:

from numpy import *
a=array([[1],[2],[2]])
print(a[0])

 输出:

[1]

 对于list:

from numpy import *
a=[[1],[2],[2]]
print(a[0])

 输出:

[1]

 

以上是关于numpy 矩阵和数组的主要内容,如果未能解决你的问题,请参考以下文章