擅长:python、mysql、java
<p>为了清楚起见</p>
<p><a href="https://stackoverflow.com/a/509295/2336654">With respect to python syntax, this question has been answered here.</a></p>
<p>Python列表切片语法声明,对于<code>a:b</code>它将得到<code>a</code>和所有的内容,但不包括<code>b</code>。<code>a:</code>将得到<code>a</code>及其之后的所有内容。<code>:b</code>将在<code>b</code>之前获得所有内容,但不会<code>b</code>。<code>-1</code>的列表索引引用最后一个元素。<code>:-1</code>遵循与上面相同的标准,这将获取最后一个元素之前的所有内容,而不是最后一个元素。如果要包含最后一个元素,请使用<code>:</code>。</p>