python取二維數組中的某一列

list a=[[1,2,3], [4,5,6]] a[:, 0] # 嘗試用數組的方法讀取一列失敗 TypeError: list indices must be integers or slices, not tupleweb numpy array 轉爲array便可 a = np.array(a) a[:, 0] array([1, 4])數組 array轉list a.tolist()s
相關文章
相關標籤/搜索