from sympy import *
matrix = []
print("Enter the entries of the 3x3 matrix:")
for i in range(0,3):
a =[]
for j in range(0,3):
a.append(int(input()))
matrix.append(a)
for i in range(0,3):
for j in range(0,3):
print(matrix[i][j], end = " ")
print()
for i in range(0,3):
for j in range(0,3):
M[i][j]=list(matrix[i][j])
M_rref = M.rref()
print("The Row echelon form of matrix M and the pivot columns : {}".format(M_rref))
將陣列相互傳輸時出現錯誤。我只想將 3x3 矩陣轉換為梯形。TypeError:“int”物件不可迭代,有時 AttributeError:“list”物件沒有屬性“rref”
uj5u.com熱心網友回復:
只需將您的轉換matrix
為 SymPy Matrix
,如下所示:
from sympy import *
matrix = []
print("Enter the entries of the 3x3 matrix:")
for i in range(0,3):
a =[]
for j in range(0,3):
a.append(int(input()))
matrix.append(a)
for i in range(0,3):
print(matrix[i])
M = Matrix(matrix)
M_rref = M.rref()
print("The Row echelon form of matrix M and the pivot columns : {}".format(M_rref))
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/477169.html
上一篇:從串列中洗掉NOT重復值