How to extract 2 integers from a string in python?

Klaus Alexander Seistrup klaus at seistrup.dk
Fri Jun 9 07:14:05 CEST 2006


yinglcs at gmail.com skrev:

> how can I extract 2 integers from a string in python?
>
> for example, my source string is this:
> Total size: 173233 (371587)
>
> I want to extract the integer 173233 and 371587 from that 
> soource string, how can I do that?

E.g.:

#v+

>>> import re
>>> re.findall(r'\d+', 'Total size: 173233 (371587)')
['173233', '371587']
>>> 

#v-

Mvh, 

-- 
Klaus Alexander Seistrup
Copenhagen, Denmark
http://surdej.dk/



More information about the Python-list mailing list