品易云推流 关闭
文章详情页
文章 > Python常见问题 > python写代码怎么跳到下一行

python写代码怎么跳到下一行

头像

silencement

2019-12-10 10:09:2420195浏览 · 0收藏 · 0评论

Python中一般是一行写完所有代码,如果遇到一行写不完需要换行的情况,有两种方法:

1.在该行代码末尾加上续行符“ \”(即空格+\);

test = 'item_one' \
'item_two' \
  'tem_three'

输出结果:

'item_oneitem_twotem_three'

2.加上括号,() {}  []中不需要特别加换行符:

test2 = ('csdn '
'cssdn')

输出结果:

csdn cssdn

if...and:

if (where there is a will and
there is a way)

多次未输出结果

test3 =('Hello'
' '
'world')

输出结果:

Hello world

推荐学习《python教程

关注

关注公众号,随时随地在线学习

本教程部分素材来源于网络,版权问题联系站长!

底部广告图