📜  Python| numpy matrix.getA1()

📅  最后修改于: 2022-05-13 01:54:22.395000             🧑  作者: Mango

Python| numpy matrix.getA1()

借助Numpy matrix.getA1()方法,我们可以获得给定矩阵的一维 ndarray。

示例 #1:
在这个例子中,我们可以看到我们能够在方法matrix.getA1()的帮助下获得 numpy 数组。

# import the important module in python
import numpy as np
          
# make matrix with numpy
gfg = np.matrix('[6; 2; 3]')
          
# applying matrix.getA1() method
geeks = gfg.getA1()
    
print(geeks)
输出:
[6 2 3]

示例 #2:

# import the important module in python
import numpy as np
          
# make a matrix with numpy
gfg = np.matrix('[1, 2, 3; 4, 5, 6; 7, 8, 9]')
          
# applying matrix.getA1() method
geeks = gfg.getA1()
    
print(geeks)
输出:
[1 2 3 4 5 6 7 8 9]