Extracting int from string

Ben Caradoc-Davies ben at wintersun.org
Mon Jan 13 17:31:38 EST 2003


On 13 Jan 2003 22:02:29 GMT, Spencer Ernest Doidge <spencer at efn.org> wrote:
> What would be the best way to extract the integer value 45 from the following string?
> 'X=   45   A'

I would use

    int(s.split()[1])

where s is bound to the string.

-- 
Ben Caradoc-Davies <ben at wintersun.org>
http://wintersun.org/
Imprisonment on arrival is the authentic Australian immigration experience.




More information about the Python-list mailing list