目录
1.mat()
copy的值默认是False 所以我们推荐使用mat()创建矩阵
可以用字符串的形式创建,也可以用列表的形式创建
import numpy as np
# 字符串
m1=np.mat('1 2 3;2 3 4;3 4 5')
print('m1:',m1)
print(type(m1)) # <class 'numpy.matrix'>
# 列表
m2=np.mat([[1,2,3],[2,3,4],[3,4,5]])
print('m2:',m2)
2.matrix()
copy参数的值默认是True
import numpy as np
# 字符串
m3=np.matrix('1 2 3;2 3 4;3 4 5')
print('m3:',m3)
print(type(m3)) # <class 'numpy.matrix'>
# 列表
m4=np.matrix([[1,2,3],[2,3,4],[3,4,5]])
print('m4:',m4)