清單使用切片
如圖:
import numpy as np
a = [[1,2,3,4],
[2,3,4,5],
[3,4,5,6]
]
#a = np.array(a)
print(a[:,1])
将出現錯誤: TypeError: list indices must be integers or slices, not tuple
将把清單a轉為數組後,就可以了
輸入結果:[2 3 4]
清單使用切片
如圖:
import numpy as np
a = [[1,2,3,4],
[2,3,4,5],
[3,4,5,6]
]
#a = np.array(a)
print(a[:,1])
将出現錯誤: TypeError: list indices must be integers or slices, not tuple
将把清單a轉為數組後,就可以了
輸入結果:[2 3 4]