如何提取Python中定义文本后面的段落?

2024-09-28 21:39:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个以下格式的文本文件,其中某些段落用一组星号标记,如下所示:

This 'impossibility' is the inspiration of his work.

********
There are no methods that comprehend his subject.

使用Python,如何仅提取星号集后面的段落


Tags: ofthe标记is格式星号thisare
1条回答
网友
1楼 · 发布于 2024-09-28 21:39:01

您可以这样做:

string = "******** There are no methods that comprehend his subject."
paragraph = string[string.find("********")+8:]

where string.find在段落中查找特定字符串的索引,并向其中添加8,因为这是有多少个星号

相关问题 更多 >