用于在文件中注释输入/输出行的脚本。
fcomments的Python项目详细描述
F命令
管理命令行中的注释
使用量
默认行为是切换行。意思是如果一个匹配的行 被注释,注释将被删除,如果行没有 评论评论将被添加。
指定-c标志确保匹配的行被注释掉 命令之后。flag-u的工作方式类似于 取消注释行。
资源调配
fromfcommentsimportCommenterLINES=[4,5,6]c=Commenter(path='path/to/file')c.comment_file(comment=True,lines=LINES)# ensure that lines 4-6 are commented outaction()# do sth: run tests, make migrations ..c.comment_file(uncomment=True,lines=LINES)# ensure that lines 4-6 are not commented
cli
# comment all lines in a file: $ fcomments --comment --all path/to/file $ fcomments -ca path/to/file # comment lines 3 to 12: $ fcomments --comment --lines=3-12 path/to/file $ fcomments -cl3-12 path/to/file