开发者

What is :: (double colon) in numpy like in myarray[0::3]? [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

What is :: (double colon) in Python?

I read the question What is :: (double colon) in开发者_StackOverflow中文版 Python when subscripting sequences?, but this not answer what myarray[x::y] mean.


It prints every yth element from the list / array

>>> a = [1,2,3,4,5,6,7,8,9]
>>> a[::3]
[1, 4, 7]

The additional syntax of a[x::y] means get every yth element starting at position x

ie.

>>> a[2::3]
[3, 6, 9]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜