1
所以我希望能够采取矩阵的列,做它想要的操作,然后将它放回我以为matrix.What,是我走的矩阵转置之,对列做了手术,然后它移调我again.For矩阵转置,我有:采取从矩阵的列?
def transpose(matrix):
return list(map(list, zip_longest(*matrix, fillvalue=0)))
然后我的功能来管理栏,我想:
def gestion_colonne(matrix):
matrix = transpose(matrix)
print(matrix) # to see if the matrix was transposed
column = int(input('wich column to modify?'))
alist = matrix[column-1]
list_manage(alist) #send the column to the menu that do operation on it(ex:reverse it,sort it...)
matrix = list(map(list, zip_longest(*matrix, fillvalue=0))) #transpose again to row turn to initial column
但是,代码不工作,但它确实modifiy行,但不是专栏,有时它根本没有做任何事情。
使用numpy的考虑? – dawg
你有没有示例矩阵?这些稀疏矩阵? – dawg