Mt. Everest is the highest peak in the world. It's height is 8848 m.
我如何将其分成两句话?除了' Mt'?之外不要把它分开。规则是每当Mt跟随一个点时,它需要跳过它。
这样的事情:
Mt. Everest is the highest peak in the world.
It's height is 8848 m.
到目前为止代码
data = "Mt. Everest is the highest peak in the world. It's height is 8848 m."
sentences=data.split(".")
print (sentences)
答案 0 :(得分:2)
使用负向外观以避免在Mt
之后出现点时分裂。
re.split('(?<!Mt)\. ', s)
<强>代码强>:
>>> s = "Mt. Everest is the highest peak in the world. It's height is 8848 m."
>>> re.split('(?<!Mt)\. ', s)
['Mt. Everest is the highest peak in the world', "It's height is 8848 m"]