从矩阵中提取列

时间:2013-03-29 01:58:36

标签: matrix python-3.x user-defined-functions extraction

好吧所以我只是想知道如何从矩阵中提取列。这将使用函数中定义的用户。

所以例如:

D = [[2,9], [5,2], [1,0]]
def col(B,j):


print(col(D,0))

会导致:     [2,5,1]

编辑:没关系自己想出来

def col(B,j):
    Z=[]
    for i in range(len(B)):
        Z.append(B[i][j])

    return Z

1 个答案:

答案 0 :(得分:0)

def col(B,j):
    Z=[]
    for i in range(len(B)):
        Z.append(B[i][j])
    return Z