更新时间:2022-11-25 18:24:18
不使用掩码数组,您可以删除大于或等于5的索引,如下所示:
Without using masked arrays, you could remove the indices greater or equal to 5 like this:
print input[indices[indices<5]]
编辑:请注意,如果您还想丢弃负指数,可以写下:
note that if you also wanted to discard negative indices, you could write:
print input[indices[(0 <= indices) & (indices < 5)]]