convert string number to real number - ValueError: invalid literal for int() with base 10: '"2"'

D'Arcy J.M. Cain darcy at druid.net
Sat Mar 1 00:12:31 CET 2008


On Fri, 29 Feb 2008 13:32:15 -0800 (PST)
"SPGIMail at gmail.com" <SPGIMail at gmail.com> wrote:
> 
> > You have to get rid of the double quotes first.
> 
> you mean replace them with nothing?
> 
> li[4].replace('"','')

Sure, that will do.  However, look at the csv module for another way of
handling this.

> once i do that, i should be able to use them as numbers.

You still need to apply int() or float() to the result.

-- 
D'Arcy J.M. Cain <darcy at druid.net>         |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.



More information about the Python-list mailing list