📜  Python| numpy matrix.tobytes()

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

Python| numpy matrix.tobytes()

借助Numpy matrix.tobytes()方法,我们可以使用matrix.tobytes()方法找到矩阵的字节码。

示例 #1:
在这个例子中,我们可以看到通过使用matrix.tobytes()方法,我们能够找到给定矩阵的字节码。

# import the important module in python
import numpy as np
              
# make matrix with numpy
gfg = np.matrix('[4, 1; 12, 3]')
              
# applying matrix.tobytes() method
geek = gfg.tobytes()
    
print(geek)
输出:

示例 #2:

# import the important module in python
import numpy as np
              
# make matrix with numpy
gfg = np.matrix('[4, 1, 9; 12, 3, 1; 4, 5, 6]')
              
# applying matrix.tobytes() method
geek = gfg.tobytes()
    
print(geek)
输出: