import numpy as np
# 一维数组
a = np.array([1, 2, 3, 4, 5])
print(a[..., 1]) # 等同于 a[1],输出:2
# 二维数组
b = np.array([[1, 2], [3, 4], [5, 6]])
print(b[..., 1]) # 等同于 b[:, 1],输出:[2 4 6]
print(b[1, ...]) # 等同于 b[1, :],输出:[3 4]
# 三维数组
c = np.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])
print(c[..., 1]) # 等同于 c[:, :, 1],输出:[[2 4][6 8]]
print(c[1, ..., 1]) # 等同于 c[1, :, 1],输出:[6 8]

print(c[…, 1]) # 等同于 c[:, :, 1],输出:[[2 4][6 8]]:

推薦hahow線上學習python: https://igrape.net/30afN




![Excel TQC考題202: 快樂小學學生名冊,自訂格式:0″公斤”;[紅色]”減”0″公斤”;[藍色]”完美身材” Excel TQC考題202: 快樂小學學生名冊,自訂格式:0″公斤”;[紅色]”減”0″公斤”;[藍色]”完美身材”](https://i2.wp.com/savingking.com.tw/wp-content/uploads/2022/04/20220410142405_70.png?quality=90&zoom=2&ssl=1&resize=350%2C233)



![Python提取2D array的一部份資料; import numpy; a[1: , 2:] ; a[1:-1 , 2:-1] Python提取2D array的一部份資料; import numpy; a[1: , 2:] ; a[1:-1 , 2:-1]](https://i2.wp.com/savingking.com.tw/wp-content/uploads/2022/09/20220906122441_97.png?quality=90&zoom=2&ssl=1&resize=350%2C233)

近期留言