擅长:python、mysql、java
<p>使用<code>reverse()</code>函数</p>
<pre><code>>>> InputArray = ['Good', 'better', 'Best', 'Fantastic', 'perfect', 'Super', 'Fine', 'Great']
>>> middle = len(InputArray)/2
>>> Output = InputArray[middle:] + InputArray[:middle] # swap the last half with the first half
>>> Output.reverse() # reverse the list in-place
>>> Output
['Fantastic', 'Best', 'better', 'Good', 'Great', 'Fine', 'Super', 'perfect']
</code></pre>
<p><strong>说明:</strong></p>
<p><code>InputArray[middle:]</code>返回从索引<code>middle</code>到结尾的子列表
<code>InputArray[:middle]</code>返回从索引0到<code>middle - 1</code>的子列表</p>
<p>或者你可以用这一层</p>
^{pr2}$
<p><strong>说明:</strong></p>
<p><code>InputArray[middle-1::-1]</code>返回从索引<code>middle-1</code>到0的子列表<br/>
<code>InputArray[:middle-1:-1]</code>返回从index end到<code>middle - 1</code>的子列表</p>
<p><code>[start:end:step_size]</code>第三个参数将步长设置为<code>-1</code>,因此顺序相反。在</p>