python多行语句

多行语句

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

total = item_one + \
        item_two + \
        item_three

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

total = ['item_one', 'item_two', 'item_three',
        'item_four', 'item_five']
posted @ 2019-11-04 16:54  一只竹子  阅读(3253)  评论(0编辑  收藏  举报