如题
>>> import numpy as np >>> A = np.mat('1 2;3 4') >>> A matrix([[1, 2], [3, 4]]) >>> A[0],A[1] = A[1],A[0] >>> A matrix([[3, 4], [3, 4]]) >>>
为什么交换无效顺便求Python矩阵变换的相关资料
光阴似箭催人老,日月如移越少年。
Write like this:
A[[0,1]] = A[[1,0]] // 上面相当于 A[[0,1],:] = A[[1,0],:]
As for information, it is recommended that you read NumPy’s official documentation (or domestic technical blogs about NumPy)
Write like this:
As for information, it is recommended that you read NumPy’s official documentation (or domestic technical blogs about NumPy)