有没有一种机制可以注释掉大块Python代码?
现在,我能看到的注释代码的唯一方法是用#
,或者将代码括在三引号中:"""
.
这些的问题是插入#
在每一行都很麻烦之前"""
使我想用作注释的字符串显示在生成的文档中。
读完所有评论后,答案似乎是“否”。
Python does not have such a mechanism. Prepend a #
to each line to block comment. For more information see PEP 8 http://www.python.org/dev/peps/pep-0008/. Most Python IDEs support a mechanism to do the block-commenting-with-hash-signs automatically for you. For example, in IDLE on my machine, it's Alt+3 and Alt+4.
不要使用三引号;正如您所发现的,这是针对文档字符串而不是块注释,尽管它具有类似的效果。如果您只是暂时注释掉一些内容,那么作为临时措施就可以了。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)