Python的注释 与代码块表示

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_35091777/article/details/80889108

多行注释可以用多个 # 号,还有 ''' 和 """

#!/usr/bin/python3

# 第一个注释

# 第二个注释

'''第三注释

第四注释

'''

"""

第五注释

第六注释

"""

print ("Hello, Python!")

python最具特色的就是使用缩进来表示代码块,不需要使用大括号 {} 。

缩进的空格数是可变的,但是同一个代码块的语句必须包含相同的缩进空格数。

python 的多行语句

Python 通常是一行写完一条语句,但如果语句很长,我们可以使用反斜杠(\)来实现多行语句,例如:

total = item_one + \
        item_two + \
        item_three

在 [], {}, 或 () 中的多行语句,不需要使用反斜杠(\),例如:

total = ['item_one', 'item_two', 'item_three',
        'item_four', 'item_five']



猜你喜欢

转载自blog.csdn.net/qq_35091777/article/details/80889108