擅长:python、mysql、java
<p>您可以使用<a href="https://stackoverflow.com/questions/509211/good-primer-for-python-slice-notation">slices</a>来实现:</p>
<pre><code>>>> l = ["line1","line2","line3","line4"] # don't use "list" as variable name, it's a built-in.
>>> print l[2:] # to discard items up to some point, specify a starting index and no stop point.
['line3', 'line4']
>>> print l[:1] + l[3:] # to drop items "in the middle", join two slices.
['line1', 'line4']
</code></pre>