Py学习  »  Urvi Soni  »  全部回复
回复总数  1
4 年前
回复了 Urvi Soni 创建的主题 » 使用python识别段落中的第一个句子

你可以试试这个。。。

txt = " ECONOMYNEXT -Sri Lanka rupee closed steady at 176.40/50 rupees to the US 
        dollar on Friday and gilt yields edged higher on profit taking in the 
        secondary market even as the Central Bank cut policy rates to revive credit 
        demand, while stocks ended 0.26 percent lower, market participants said. The 
        rupee ended at 176.40/50 rupees against the greenback in the spot market on 
        Thursday. "

sentence_index = txt.find('. ')

print(txt[0: sentence_index])

你将得到如下输出

ECONOMYNEXT-市场人士表示,斯里兰卡卢比兑美元周五收稳在176.40/50卢比,金边收益率小幅上升,因二级市场获利回吐,尽管央行下调政策利率以恢复信贷需求,但股市收跌0.26%