Python输出文本在终端中的间距问题
我最近在尝试使用Python,想了解它可以做些什么。所以我需要一些关于输出到命令行的代码的帮助。
现在这段代码看起来是这样的:
"print ("Hello and welcome to my world")
"print ("I'd like you to meet my family")
它在命令行中输出为:
Hello and welcome to my world
I'd like you to meet my family
有没有什么命令可以在这两行输出之间加个空行,让它看起来像这样呢?:
Hello and welcome to my world
I'd like you to meet my family
谢谢!
3 个回答
0
只需要在第一行加一个换行符就可以了:
print ("Hello and welcome to my world\n")
0
只要在你想换行的地方加上\n
就可以了。
2
如果你使用的是Python 2,
print ("Hello and welcome to my world")
print
print ("I'd like you to meet my family")
或者如果你使用的是Python 3,
print ("Hello and welcome to my world")
print ()
print ("I'd like you to meet my family")
或者你可以使用\n
。这个方法在任何版本的Python中都可以用。
print ("Hello and welcome to my world\n")
print ("I'd like you to meet my family")