Conversion of string to integer
Wojciech Muła
wojciech_mula at poczta.null.onet.pl.invalid
Mon Jan 29 09:10:34 EST 2007
More information about the Python-list mailing list
Mon Jan 29 09:10:34 EST 2007
- Previous message (by thread): Conversion of string to integer
- Next message (by thread): Conversion of string to integer
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
jupiter wrote: > I have a problem. I have a list which contains strings and numeric. > What I want is to compare them in loop, ignore string and create > another list of numeric values. > > I tried int() and decimal() but without success. > > eq of problem is > > #hs=string.split(hs) > hs =["popopopopop","254.25","pojdjdkjdhhjdccc","25452.25"] tmp = [] for s in hs: try: tmp.append( float(s) ) except ValueError: # function float raises VE, if string 's' doesn't # represent a number pass # tmp contains a list of floats
- Previous message (by thread): Conversion of string to integer
- Next message (by thread): Conversion of string to integer
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list