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



![Python: 如何在pandas.read_csv() or pandas.read_excel() 中使用keep_default_na =False , na_values =[] 保留文件中的原始“NA”? Python: 如何在pandas.read_csv() or pandas.read_excel() 中使用keep_default_na =False , na_values =[] 保留文件中的原始“NA”?](https://i0.wp.com/savingking.com.tw/wp-content/uploads/2024/05/20240530215737_0.png?quality=90&zoom=2&ssl=1&resize=350%2C233)

![Python: list.index() 只能找到第一個元素的index,若元素有重複,如何找出所有index? indexes = [index for index, value in enumerate(my_list) if value == target] Python: list.index() 只能找到第一個元素的index,若元素有重複,如何找出所有index? indexes = [index for index, value in enumerate(my_list) if value == target]](https://i0.wp.com/savingking.com.tw/wp-content/uploads/2024/10/20241010101216_0_12b6c0.png?quality=90&zoom=2&ssl=1&resize=350%2C233)




近期留言