Sequence[start:end:step]
step的正负决定了切片的方向。
step为正,左→右,若start>end,结果为空,因为start右边无值
step为负,右→左,若start<end,结果为空,因为start左边无值
若start为空,则表示最开始位置
若end为空,则表示最后位置
若start和end都为空,则表示全部元素。
如:
>>> a='0123456'
>>> a[1:5]
'1234'
返回结果是1234,能理解么?第一位到第五位切片(初始是0位)
>>> a[1:5:2]
'13'
In : d = np.arange(0,9)
Out: array([0, 1, 2, 3, 4, 5, 6, 7, 8])
In : e = d[::-1]
Out: array([8, 7, 6, 5, 4, 3, 2, 1, 0])
In : np.dot(d,e)
Out: 84