因此,我想在语句末尾打印一个带有感叹号的字符串,但最后一个单词和感叹号之间没有任何空格。 例如:
name = raw_input('Insert your name: ')
现在,我想让 python 打印这样的东西:
Your name is John!
所以,我输入:
print 'Your name is', name, '!'
它返回给我:
Your name is John !
我想做的是去掉“John”和感叹号之间的空格。
有什么想法吗?
请您参考如下方法:
使用字符串格式:
print 'Your name is {}!'.format(name)
或:
print 'your name is %s!' %name
