gpt4 book ai didi

python - 在文本文件中创建带有句点(句点)的新行

转载 作者:太空宇宙 更新时间:2023-11-04 09:04:19 25 4
gpt4 key购买 nike

<分区>

我想在 python 中显示文本文件中的一个句子,但我想在每个句点(句点)后显示它,新行开始。

例如我的段落是

"Dr. Harrison bought bargain.co.uk for 2.5 million pounds, i.e. he
paid a lot for it. Did he mind? John Smith, Esq. thinks he didn't.
Nevertheless, this isn't true... Well, with a probability of .9 it
isn't."

但我希望它显示如下

"Dr. Harrison bought bargain.co.uk for 2.5 million pounds, i.e. he
paid a lot for it.
Did he mind? John Smith, Esq. thinks he didn't.
Nevertheless, this isn't true...
Well, with a probability of .9 it isn’t."

句子中出现的其他句号(例如网站地址中的“Dr.”、“Esq.”)让这变得越来越困难'.9',当然还有省略号中的前两个点。

对于文本文件中存在的其他时期,我不确定如何处理这个问题,有人可以帮忙吗?谢谢。

“你的任务是编写一个程序,给定一个文本文件的名称,它能够编写它的每个句子的内容单独一行。” <-- 任务集

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com