1.6 注释
注释的主要起备注功能。对于个人来说,注释可以帮助个人回顾以前写过的代码。对于团队协作来说,因为个人编写的代码要被多人调用,所以需要使用注释来帮助他人理解自己编写的代码。
Python中的注释分为单行与多行注释。单行注释以”#”开头,后边跟注释语句:
>>> # 输出hello world
print("hello world!")
多行注释用三个单引号 ''' 或者三个双引号 """ 将注释括起来:
>>>’’’
输出hello world
输出hello world
输出hello world
‘’’
print(“hello world!”)
hello world
使用双引号进行注释:
>>>’’’
输出hello world
输出hello world
输出hello world
‘’’
print(“hello world!”)
hello world
Last updated
Was this helpful?