擅长:python、mysql、java
<p>您可以使用文件迭代器上的<code>next()</code>跳过第一行,然后使用<code>file.writelines</code>写入其余内容:</p>
<pre><code>with open(filenamex, 'rb') as currentx, open('foobar', 'w') as data:
next(currentx) #drop the first line
data.writelines(currentx) #write rest of the content to `data`
</code></pre>
<p><strong>注意:</strong>不要使用<code>file.read()</code>如果您想逐行读取文件,只需遍历file对象即可一次获取一行。你知道吗</p>