a=[ [1,2,3], [4,5,6], [7,8,9], [10,11,12] ] 方式1: result_list = [] for i in range(3): list_inner = [] #定义一个list存放新二维数组的每行元素,存放原列表的每列元素 for l in a: list_inner.append(l[i]) result_list.append(list_inner) print result_list
方式2:一行 print [ [l[i] for l in a] or i in range(3)]
删除二维矩阵的某一列 只保存某些列 s a=[ [1,2,3], [4,5,6], [7,8,9], [10,11,12] ]