a = range(10) a [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
a[2] 2 a[-2] 8 a[2:] [ 2, 3, 4, 5, 6, 7, 8, 9] a[:2] [0, 1 ] a[2:6] [ 2, 3, 4, 5 ] a[2:-2] [ 2, 3, 4, 5, 6, 7 ] a[-6:-2] [ 4, 5, 6, 7 ] a[:] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] a[::2] [0, 2, 4, 6, 8 ] a[2::2] [ 2, 4, 6, 8 ] a[:6:2] [0, 2, 4 ] a[2:6:2] [ 2, 4 ] a[::-1] [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
|