Python多行注释教程及示例

注释用于将一些文本放入Python代码中。本文可以用来解释有关应用程序或某些方法数据等的内容 Single Line Multi-Line .

null

单行注释

# 用于创建单行注释。我们会把 # 并将整行解释为注释,并且不会执行命令。

# This is a single line commentprint("Hello Poftut.com")#This is another  single line commentprint("Hello Poftut.com")  #This is a single line comment too

多行注释

Python还提供了多行字符串,它在我们的代码中是三重引号。我们将用三个引号来开始多行注释,用三个引号来结束多行字符串。

"""This is the commentfor multi lineComment"""print("Hello Poftut.com")

我们还可以通过提供注释在多行注释的开始行和结束行中使用字符串。

""" This is the start of the multiline commentThis is the body of the multiline commentThis is the end of the multiline comment"""print("Hello Poftut.com")

多行单行注释

还有另一种方法可以在Python中创建多行注释。我们可以使用多个单行注释。

# This is a single line comment# This is another single line comment# This is comment which will look like multiline commentprint("Hello Poftut.com")

注释代码

我们还可以对有效代码进行注释。这将使代码只是注释,而不会执行代码行。在本例中,我们将注释 print("Hello Poftut.com") 行,将没有输出。

# This is a comment# print("Hello Poftut.com")a = 5

相关文章: SQL注释教程及示例

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享