如何用Python编写内联注释 [英] How to write an inline-comment in Python

查看:103
本文介绍了如何用Python编写内联注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Python中是否有结束单行注释的方法?

Is there a method of ending single line comments in Python?

类似

/* This is my comment */ some more code here...


推荐答案

否,Python中没有内联注释。

No, there are no inline comments in Python.

来自文档


注释以不属于a的哈希字符()开头
字符串文字,,并在物理行的结尾结束。注释
表示逻辑行的结尾,除非调用了连接
规则的隐式行。语法将忽略注释。它们不是
令牌。

A comment starts with a hash character (#) that is not part of a string literal, and ends at the end of the physical line. A comment signifies the end of the logical line unless the implicit line joining rules are invoked. Comments are ignored by the syntax; they are not tokens.

这篇关于如何用Python编写内联注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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