Remove periods at the end of sentences in python

后端 未结 3 1890
别那么骄傲
别那么骄傲 2021-01-21 01:16

I have sentences like this - \"this is a test. 4.55 and 5,000.\" I want to remove the period at the end of the sentences, but not between numbers. My output has to be - \"this

3条回答
  •  误落风尘
    2021-01-21 01:43

    How about

    pattern = re.compile(r'\.(\s)')
    wordList = pattern.sub(r'\1', wordList)
    

    This replaces a period followed by a space with just the space.

提交回复
热议问题