python asyncio璇﹁В (python class鐢ㄦ硶鐞嗚В)

什么是程序的注释呢?

通常情况 下我们写一篇文章或者看一些文档 会对这些文档作一些批注,通常这些批注不是下方内容,只是记录当时写这个文章 的思路

有时写程序的时候涉及的业务或者逻辑、算法过于复杂。记录当时写程序的想法,表里这行代码的作用。

注释的作用

  • 注释可以用来解释 Python 代码。
  • 注释可用于使代码更具可读性。
  • 注释可用于在测试代码时防止执行
Comments can be used to explain Python code.
Comments can be used to make the code more readable.
Comments can be used to prevent execution when testing code.

注释放在行首 # 开关不的这行语句就是注释,不会被执行

#This is a comment print("Hello, World!")

注释 可以放在行尾,Python 会忽略该行的其余部分:

python代码的注释有几种,python下面的代码是什么意思

注释放在行尾部

print("Hello, World!") #This is a comment

python代码的注释有几种,python下面的代码是什么意思

多行注释:当你需要多选文本来说明代码的作用应该怎么办呢

Python 并没有真正的多行注释语法。那么每行文本前面 加个 #

#This is a comment#written in#more than just one line print("Hello, World!")

python代码的注释有几种,python下面的代码是什么意思

多行注释的另一种方式

''' '''

"""
This is a comment
written in
more than just one line
"""

print("Hello, World!")

python代码的注释有几种,python下面的代码是什么意思