how to split this kind of text into sections

Chris Angelico rosuav at gmail.com
Fri Apr 25 09:31:58 EDT 2014


On Fri, Apr 25, 2014 at 11:07 PM, oyster <lepto.python at gmail.com> wrote:
> the above text should be splitted as a LIST with 3 items, and I also need to
> know the KEY for LIST is ['I am section', 'let's continue', 'I am using']:

It's not perfectly clear, but I think I have some idea of what you're
trying to do. Let me restate what I think you want, and you can tell
be if it's correct.

You have a file which consists of a number of lines. Some of those
lines begin with the string "I am section", others begin "let's
continue", and others begin "I am using". You want to collect those
three sets of lines; inside each collection, every line will have that
same prefix.

Is that correct? If so, we can certainly help you with that. If not,
please clarify. :)

ChrisA



More information about the Python-list mailing list