【发布时间】:2012-11-30 09:31:53
【问题描述】:
我有一个大文件,我想从中读取前 3 行并将它们放入另一个文件 new.txt。之后再读3行,但不要从头开始读,应该是从第4行开始读3行。
1st line
2nd line
3rd line
4th line
5th line
6th line
7th line
8th line
9th line
10th line
....
文件 new.txt 中的第一个输出将是:
1st line
2nd line
3rd line
文件 new.txt 中的第二个输出将是:
4th line
5th line
6th line
【问题讨论】:
-
当然,你想读就读。你试过什么?
-
“new.txt 文件中的第二个输出”是什么意思?这会覆盖第一个输出,还是附加到它?这与一次复制六行有什么不同?
标签: python python-2.7 python-2.6