python中的[nm] Posted on 2020-07-19 | In python | | Visitors: Words count in article: 128 python中的[n::m]前一阵子读代码的时候发现了这样的写法,大概自己试了一下,n表示起始坐标,m表示间隔,举个例子就知道了 12import numpy as npa = np.array([1,2,3,4,5,6,7,8]) 栗子123print(a[0::2]) # 输出起始坐标为0,间隔为2print(a[1::2]) # 输出起始坐标为1,间隔为2print(a[0::4]) # 输出起始坐标为0,间隔为4 输出结果: 123[1 3 5 7][2 4 6 8][1 5]