<blockquote>
<p><strong>Possible Duplicate:</strong>
<a href="https://stackoverflow.com/questions/11349333/when-processing-csv-data-how-do-i-ignore-the-first-line-of-data">When processing CSV data, how do I ignore the first line of data?</a></p>
</blockquote>
<p>我正在使用python打开CSV文件。我正在使用公式循环,但我需要跳过第一行,因为它有标题。</p>
<p>到目前为止,我记得是这样的,但它缺少了一些东西:我不知道是否有人知道我要做什么的代码。</p>
<pre><code>for row in kidfile:
if row.firstline = false: # <====== Something is missing here.
continue
if ......
</code></pre>
<p>跳过第一行有很多方法。除了巴库留所说的以外,我还要补充:</p>
<pre><code>with open(filename, 'r') as f:
next(f)
for line in f:
</code></pre>
<p>以及:</p>
<pre><code>with open(filename,'r') as f:
lines = f.readlines()[1:]
</code></pre>