Howto parse a string using a char in python
python.list at tim.thechases.com
Sat Feb 16 00:16:26 CET 2013
On 2013-02-15 18:04, Steve Goodwin wrote:
> 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 :)
> I have looked at regular expressions and string functions, so far
> no luck. Custom function required?
With just a single character, it sounds like you want something like
whole = "123456:789"
parts = whole.split(':') # or .split(':', 1)
interesting = parts
No custom function needed.
More information about the Python-list