
上QQ阅读APP看书,第一时间看更新
1.3.1 注释
Python使用注释主要是为了方便阅读程序,共有3种注释方式,【例1.1】中使用了其中的两种。
(1)如果单行文字采用#开头,其后就是注释内容。一般采用这种注释来描述此后一段程序的功能。
例如:

(2)采用#开头,并写在一行语句或表达式的后面的注释,一般用来说明该行语句或表达式的作用。
例如:

(3)块注释(即多行注释),一般用于注释内容较多的情形。虽然块注释也可采用多行用#开头的注释来表示,但用3个单引号(' ' ')或者3个双引号(" " ")将注释进行标识会更自然。
例如:
