Howto parse a string using a char in python

Gary Chambers gwchamb at gwcmail.com
Sat Feb 16 00:13:21 CET 2013


Steve,

> I am looking for the python2.7 function(s) to parse a string from a colon 
> character ":"
> 
> Sounds simple enough.
> 
> For example, a string like "123456:789".  I just need the "123456" 
> substring.(left of the :)

How about:

newstr = str[:str.find(':')]

--
GC
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2768 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20130215/13d88d80/attachment.bin>


More information about the Python-list mailing list