小组评论 [英] Group comment
问题描述
嗨
我可以一起评论一组陈述吗
如果我有4个陈述说:
i = 1
i + = 1
打印我
打印我+ 1
而不是通过#来个人评论每个声明那个
这个东西让我一口气评论这4个陈述,如
C ++使用/*...*/
ketulp>我可以一起评论一组陈述,即
ketulp>如果我有4个陈述说:
ketulp> i = 1
ketulp> i + = 1
ketulp>打印我
ketulp>打印i + 1
ketulp>而不是通过#个人评论每个声明是
ketulp>让我一起评论这4个陈述的东西
ketulp>在C ++中使用/*...*/
许多人使用三引号字符串:
""" ;
i = 1
i + = 1
打印i
打印i + 1
"""
严格来说,这不是评论,但它通常会达到预期结果所需的
。更少的评论是如果错误::
如果错误:
i = 1
i + = 1
打印我
打印i + 1
这样做的缺点是你需要重新引导感兴趣的线条。 />
跳过
使用(x)emacs并输入
Mx评论区域
类型
Cu Mx评论区域
取消注释。当然你可以将它绑定到键。 C-C-<和C-c->将
dedent /缩进当前选择。非常有用。
-
问候,
Diez B. Roggisch
Skip Montanaro< skip< at> pobox.com>写道:
许多人为此使用三引号字符串:
"""
i = 1
i + = 1
打印i
打印i + 1
""
严格来说,这不是评论,但它通常会实现
期望的结果。
但是作为附带效果,它将被解释为文档字符串。
最好将其作为一个元组:
("""
i = 1
i + = 1
打印i
打印i + 1
""")
或者像混合动力一样:
if 0:""
i = 1
i + = 1
打印i
打印i + 1
"""
>
Hi
Can I comment a group of statements together i.e
If I a 4 statements say:
i=1
i+=1
print i
print i+1
Instead of commenting each satement iindividually by # is there
something which allws me to comment these 4 statements in one go as in
C++ using /*...*/
ketulp> Can I comment a group of statements together i.e
ketulp> If I a 4 statements say:
ketulp> i=1
ketulp> i+=1
ketulp> print i
ketulp> print i+1
ketulp> Instead of commenting each satement iindividually by # is there
ketulp> something which allws me to comment these 4 statements in one go
ketulp> as in C++ using /*...*/
Many people use triple-quoted strings for this:
"""
i=1
i+=1
print i
print i+1
"""
It''s not a comment, strictly speaking, however it generally achieves the
desired results. Even less comment-like is "if False:":
if False:
i=1
i+=1
print i
print i+1
That has the disadvantage that you need to reindent the lines of interest.
Skip
Use (x)emacs and type
M-x comment-region
Type
C-u M-x comment-region
to uncomment. Of course you can bind that to keys. C-c-< and C-c-> will
dedent/indent the current selection. Very useful.
--
Regards,
Diez B. Roggisch
Skip Montanaro <skip <at> pobox.com> writes:
Many people use triple-quoted strings for this:
"""
i=1
i+=1
print i
print i+1
"""
It''s not a comment, strictly speaking, however it generally achieves the
desired results.
But as colateral effect it will be interpreted like a doc string. It''s better to
make it as a tuple:
("""
i=1
i+=1
print i
print i+1
""")
or, like a hybrid:
if 0:"""
i=1
i+=1
print i
print i+1
"""
这篇关于小组评论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!