0

例如:

“是的……我是亚伦”

4

3 回答 3

18
"yes...I am Aaron".replace("...", "")
于 2013-04-16T09:57:24.643 回答
3

jamylak 的答案应该可以解决问题,但是,如果您使用的是 ASCII 省略号,请尝试以下操作:

>>> s = 'yes\u2026 I am Aaron'
>>> s
'yes… I am Aaron'
>>> s.replace('\u2026', '')
'yes I am Aaron'
>>>
于 2019-05-12T16:27:58.437 回答
1
>>> import re
>>> s = "1,2,3,... ,10"
>>> s = re.sub("\.\.\.", "", s)
>>> s
'1,2,3, ,10'

>>> import re
>>> print re.sub("[\.][\.][\.]", " ", "yes...I am Aaron")
yes I am Aaron
>>> print re.sub("[\.]"*3, " ", "yes...I am Aaron")
yes I am Aaron
>>> print re.sub("[\b\.\b]{3}", " ", "yes...I am Aaron")
yes I am Aaron
>>> 
于 2013-04-16T10:03:08.590 回答