Nao*_*ura 6 python strip python-2.7
说,如果我有像这样的文字
text='a!a b! c!!!'
我想要一个这样的结果:
text='a!a b c'
所以,如果每个单词的结尾都是'!',我想摆脱它.如果有多个'!' 最后,所有这些都将被淘汰.
Jor*_*ley 8
print " ".join(word.rstrip("!") for word in text.split())
归档时间:
12 年,9 月 前
查看次数:
13321 次
最近记录:
8 年,7 月 前