从文件中删除一些行 [英] To remove some lines from a file

查看:114
本文介绍了从文件中删除一些行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,


我对python很新。我想从文件中删除两行。

文件以一些注释开头,注释符号为$。文件

结构是


$

$

$

$

$

$

$

..

.. < br $> b $ b ..

..

$

line1

line 2

$

$

..

..

..

$

实际命令


我想在

文件的最开头删除这两行两个评论块。我已经阅读了有关python的内容但是我的

库知识仍然很弱。那么请你帮我这个

代码。


我想称之为


myscript targetfile


我已经读过关于命令行参数的信息。也许我可以自己应付

但是也很感激帮助。


祝你好运,

解决方案

。文件

结构是






Dear all,

I am quite new to python. I would like to remove two lines from a file.
The file starts with some comments, the comment sign is $. The file
structure is

$
$
$
$
$
$
$
..
..
..
..
$
line1
line 2
$
$
..
..
..
$
actual commands

I would like to delete those two lines at the very beginning of the
file between two comment blocks. I have read things about python but my
library knowledge is still weak. So could you please help me with this
code.

I would like to call this as

myscript targetfile

I have read sth about command line arguments. Perhaps I can cope with
that myself but help is also appreciated on that.

Best regards,

解决方案

. The file
structure is






这篇关于从文件中删除一些行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆