Python中不需要的空间

Win*_*ing 2 python python-2.7

name = raw_input ("What's your name? ")
print "Hello",name, "!"
Run Code Online (Sandbox Code Playgroud)

它返回以下内容:

What's your name? John
Hello John !
Run Code Online (Sandbox Code Playgroud)

我怎样做到这样John和John之间的空间!没出现?

顺便说一下,这是在Python-2.7中

Tim*_*ker 7

使用str.format()方法:

print "Hello {0}!".format(name)
Run Code Online (Sandbox Code Playgroud)

这种字符串格式化方法是Python 3中的新标准,应该优先%于新代码中的格式化[...].