mwh21 at cam.ac.uk
Sun Nov 28 20:34:53 CET 1999
"Troy" <trekkan at yahoo.com> writes:
> As you will be able to tell, I am new to Python so please forgive any newbie
> things I might do. =)
> What I would like to do is take a variable and parse out each of the
> pieces. Most commonly delimited by spaces. Example text:
> This is a test
> I would like to be able to pull out any of "This", "is", "a", "test"
> and be able to drop any element into a variable that I wanted.
Python 1.5.2+ (#12, Nov 19 1999, 15:00:31) [GCC 2.95.2 19991024 (release)] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import string
>>> string.split("This is a test")
['This', 'is', 'a', 'test']
> I hope this explains it enough. Thanks for any help you may be able
> to provide.
> One other thing, is there a way to tell if a substring exists in a
> string? in a basic sort of way
> if 'abc' isin '123abc456'
> Something to that effect anyway.
> Thanks for your time!
More information about the Python-list