Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #70590

Re: how to split this kind of text into sections

References <CACW-qXU3nQZY1VV+aGucqKeFjxz+OdVvmrSmSZRitj-+OvKFkA@mail.gmail.com>
Date 2014-04-25 23:31 +1000
Subject Re: how to split this kind of text into sections
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.9493.1398432720.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, Apr 25, 2014 at 11:07 PM, oyster <lepto.python@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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: how to split this kind of text into sections Chris Angelico <rosuav@gmail.com> - 2014-04-25 23:31 +1000

csiph-web