Py学习  »  Python

使用python识别段落中的第一个句子

Haz • 4 年前 • 274 次点击  

我想用python从一个段落中得到第一句话。 以下段落

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

周四,在现货市场上,卢比兑美元收于176.40/50卢比。

我是从下面的代码中提取这个句子的 小数点。谢谢你的帮助。

import requests
#from pprint import pprint
from IPython.display import HTML
import json


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. '''

if len(txt) > 100:
    txt = txt.partition('.')[0] + '.'
print(txt)
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/49237
 
274 次点击  
文章 [ 2 ]  |  最新文章 4 年前