Parsing a string question....

Simon Brunning SBrunning at trisystems.co.uk
Tue Oct 15 12:27:56 EDT 2002


> From:	Allan Waddington [SMTP:va3alw at rac.ca]
> 
> I have a string that is 30 characters long.  What function would I use to
> look at characters 15 to 25 or 1 to 14 in this string?
> 
> Thanks for the help.
 
You want string slicing:

>>> mystring = '123456789012345678901234567890'
>>> mystring[14:25]
'56789012345'
>>> mystring[0:14]
'12345678901234'

See
<http://www.python.org/doc/current/tut/node5.html#SECTION0051200000000000000
00>.

Cheers,
Simon Brunning
TriSystems Ltd.
sbrunning at trisystems.co.uk




-----------------------------------------------------------------------
The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorised. If you are not the intended recipient, any disclosure,
copying, distribution, or any action taken or omitted to be taken in
reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot
accept liability for statements made which are clearly the senders own.




More information about the Python-list mailing list