从文件中删除一些行

从文件中删除一些行

本文介绍了从文件中删除一些行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 亲爱的, 我对python很新。我想从文件中删除两行。 文件以一些注释开头,注释符号为$。文件 结构是 $ $ $ $ $ $ $ .. .. 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 filestructure is$$$$$$$........$line1line 2$$......$actual commandsI would like to delete those two lines at the very beginning of thefile between two comment blocks. I have read things about python but mylibrary knowledge is still weak. So could you please help me with thiscode.I would like to call this asmyscript targetfileI have read sth about command line arguments. Perhaps I can cope withthat myself but help is also appreciated on that.Best regards, 解决方案 . The filestructure is 这篇关于从文件中删除一些行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-24 21:03