- 零基础Python学习笔记
- 明日科技编著
- 264字
- 2024-01-24 15:57:27
1.2.2 多行注释
在Python中,并没有一个单独的多行注释标记,而是将包含在一对三引号('''……''')或("""……""")之间的代码都称为多行注释。这样的代码将被Python解释器忽略。由于这样的代码可以分为多行编写,所以也可以作为多行注释。
语法格式如下:


或者

多行注释通常用来为Python文件、模块、类或函数等添加版权、功能等信息,例如,下面代码将使用多行注释为程序添加功能、开发者、版权、开发日期等信息。

多行注释也经常用来解释代码中重要的函数、参数等信息,以便于后续开发者维护代码,例如:

多行注释其实可以采用单行代码多行书写的方式实现,如上面的多行注释可以写成如下形式:
