Split string with multiple-character delimiter

前端 未结 3 610
慢半拍i
慢半拍i 2020-12-01 23:47

say I have the following string:

"Hello there. My name is Fred. I am 25.5 years old."

I want to split this into sentences, so that

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-02 00:12

    >>> "Hello there. My name is Fred. I am 25.5 years old.".rstrip(".").split(". ")
    ['Hello there', 'My name is Fred', 'I am 25.5 years old']
    

提交回复
热议问题