标签: python syntax numpy slice
可能重复: What is :: (double colon) in Python?
我读了What is :: (double colon) in Python when subscripting sequences?这个问题,但这不能回答myarray [x :: y]的意思。
答案 0 :(得分:48)
它打印列表/数组
>>> a = [1,2,3,4,5,6,7,8,9] >>> a[::3] [1, 4, 7]
[x :: y]的附加语法意味着从位置x开始每个y th 元素
即
>>> a[2::3] [3, 6, 9]