切片符号简而言之:
[ <first element to include> : <first element to exclude> : <step> ]
如果要在反转列表时包括第一个元素,则将中间元素留空,如下所示:
foo[::-1]
您还可以在这里找到有关Python切片的一些很好的信息:
Understanding slice notation

切片符号简而言之:
[ <first element to include> : <first element to exclude> : <step> ]
如果要在反转列表时包括第一个元素,则将中间元素留空,如下所示:
foo[::-1]
您还可以在这里找到有关Python切片的一些很好的信息:
Understanding slice notation