>>list1 = [1, 2, 3, 4, 5, 6, 7, 8, 9]
要想获得[9, 8, 7, 6, 5, 4, 3, 2, 1]:
>>> list1[::-1] # 表达形式1
[9, 8, 7, 6, 5, 4, 3, 2, 1]
>>> list1[-1::-1] # 表达形式2
[9, 8, 7, 6, 5, 4, 3, 2, 1]
>>> list1[::-10:-1] # 不可!!!
SyntaxError: invalid syntax
----------------
要想获得[1, 2, 3, 4, 5, 6, 7, 8, 9]:
>>> list1[:] # 表达形式1
[1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> list1[::] # 表达形式2
[1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> list1[0:] # 表达形式3
[1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> list1[0::] # 表达形式4
[1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> list1[:10] # 表达形式5
[1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> list1[::10] # 不可!!!
[1]
>>> list1[0:10] # 表达形式6
[1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> list1[0::10] # 不可!!!
[1] |