import numpy as np
A = np.mat([[1,2,3],[4,5,6],[7,8,9]])
print(A.T)
print(A.swapaxes(0, 1))
# 均输出
# [[1 4 7]
# [2 5 8]
# [3 6 9]]
import numpy as np
A = [[1,2,3],[4,5,6],[7,8,9]]
print(np.transpose(A))
# 输出
# [[1 4 7]
# [2 5 8]
# [3 6 9]]
import numpy as np
A = np.mat([[1,2,3],[4,5,6],[7,8,9]])
print(A.T)
print(A.swapaxes(0, 1))
# 均输出
# [[1 4 7]
# [2 5 8]
# [3 6 9]]
import numpy as np
A = [[1,2,3],[4,5,6],[7,8,9]]
print(np.transpose(A))
# 输出
# [[1 4 7]
# [2 5 8]
# [3 6 9]]