Python - 删除字符串中的空格

Thi*_* G. 1 python

所以,我想在语句的末尾打印一个带有感叹号的字符串,但在最后一个单词和感叹号之间没有任何空格.例如:

name = raw_input('Insert your name: ')
Run Code Online (Sandbox Code Playgroud)

现在,我希望python打印这样的东西:

你的名字是约翰!

所以,我输入:

print 'Your name is', name, '!'
Run Code Online (Sandbox Code Playgroud)

它让我回报:

你的名字是约翰!

我想要做的是删除"约翰"和感叹号之间的空格.

有任何想法吗?

Rik*_*ggi 14

使用字符串格式:

print 'Your name is {}!'.format(name)
Run Code Online (Sandbox Code Playgroud)

要么:

print 'your name is %s!' %name
Run Code Online (Sandbox Code Playgroud)