更优雅的方式来制作太空蟒蛇

时间:2013-07-19 06:49:10

标签: python printing whitespace

我不知道这个问题是否可以回答。我是python的新手。我一直在使用命令print在输出到python idle shell中创建一个空格。

我想知道是否有一种更容易或更优雅的方式在输出中创建这个空白区域,或者打印这是唯一可行的方法吗?

1 个答案:

答案 0 :(得分:2)

在最后添加new line

print 'hello\n'
print 'hi'

打印:

hello

hi

这对于接收输入非常有帮助,因为你不能只在输入的中间插入print

name = raw_input("What is your name?\n> ")
print "Hello {}!".format(name)

运行时:

What is your name?
> Haidro
Hello Haidro!