【python3】基本语法

编码

# -*- coding: utf-8 -*-

注释

# 单行注释

'''
多行注释
多行注释
'''

"""
多行注释
多行注释
"""

输出

print(str)

输入

input("\n\n按下 enter 键后退出。")

行与缩进

python最具特色的就是使用缩进来表示代码块。

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

多行语句

可以使用反斜杠 \ 来实现多行语句

total = 'item_one' + \
        'item_two' + \
        'item_three'

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

total = ['item_one', 'item_two', 'item_three',
        'item_four', 'item_five']
posted @ 2022-06-08 23:12  hzyuan  阅读(54)  评论(0)    收藏  举报