为什么Python没有多行注释? [英] Why doesn't Python have multiline comments?

查看:135
本文介绍了为什么Python没有多行注释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我知道三重引号字符串可以作为多行注释。例如,

OK, I'm aware that triple-quotes strings can serve as multiline comments. For example,

"""Hello, I am a 
   multiline comment"""

'''Hello, I am a 
   multiline comment'''

但从技术上讲, ,正确?

But technically speaking these are strings, correct?

我已经搜索并阅读了Python风格指南,但是我找不到一个技术答案为什么没有正式实现multiline,/ * * /注释类型。

I've googled and read the Python style guide, but I was unable to find a technical answer to why there is no formal implementation of multiline, /* */ type of comments. I have no problem using triple quotes, but I am a little curious as to what led to this design decision.

推荐答案

我怀疑是什么意思你会得到一个更好的答案比,Guido没有觉得需要多行评论。

I doubt you'll get a better answer than, "Guido didn't feel the need for multi-line comments".

Guido已对此发表了推文


Python提示:您可以将多行字符串用作多行注释。除非用作docstrings,否则它们不会生成代码! : - )

Python tip: You can use multi-line strings as multi-line comments. Unless used as docstrings, they generate no code! :-)

这篇关于为什么Python没有多行注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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