📜  python 对特定索引求和 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:55.438000             🧑  作者: Mango

代码示例1
# You can use sum directly after indexing with indices:
a = np.array([1,2,3,4])
indices = [0, 2] 
a[indices].sum()
# Result: 4