python如何另起一行?

Python017

python如何另起一行?,第1张

方法有三种,分别是:1、在需要另起一行的地方输入三个单引号(''');2、在需要另起一行的地方输入三个双引号(""");3、在需要另起一行的地方输入反斜杠()。

python 字符串换行的三种方式:

#第一种:三个单引号

print ''' 我是一个程序员

我刚开始学习python'''

#第二种:三个双引号

print """ 我是一个程序员

我刚开始学习python"""

#第三种:结尾

print "我是一个程序员,

我刚开始学python"

推荐教程:《python教程》以上就是小编分享的关于python如何另起一行?的详细内容希望对大家有所帮助,更多有关python教程请关注环球青藤其它相关文章!

>>>print('This is the first line.\nThis is the second line.')

This is the first line.

This is the second line.