Python: How to get values of an array at certain index positions?

后端 未结 5 1025
执念已碎
执念已碎 2020-12-06 05:04

I have a numpy array like this:

a = [0,88,26,3,48,85,65,16,97,83,91]

How can I get the values at certain index positions in ONE step? For e

5条回答
  •  感动是毒
    2020-12-06 05:31

    your code would be

    a = [0,88,26,3,48,85,65,16,97,83,91]

    ind_pos = ind_pos = [a[1],a[5],a[7]]

    print ind_pos

    you get [88, 85, 16]

提交回复
热议问题