【发布时间】:2009-11-02 03:02:23
【问题描述】:
好的,我有一个文本文件,下面有示例内容
line1with some random stuff here
line 2 with something very completely different
line3 has some other neat stuff
line4 is the last line in the textfile
我需要获取该文本文件,删除一行,并保留文件的其余部分。所以如果我想删除第 2 行,id 想要这样的结果:
line1with some random stuff here
line3 has some other neat stuff
line4 is the last line in the textfile
请注意,我不想在两行之间留下任何空间。
~请提供代码示例!即使这是不可能的,任何帮助将不胜感激! :)
【问题讨论】:
-
删除一行,保持文件完整:这很矛盾
-
如果不玩语义,你真的无法理解他的意思吗?
-
好吧,我看不出是不是原来的文件实际上被留下了,而另一个创建或修改的文件取代了第一个。
-
为什么投反对票?这不是编程相关的吗?