On Sat, Nov 7, 2009 at 8:17 PM, Peng Yu <pengyu...@gmail.com> wrote: > It seems that int() does not convert '1e7'. I'm wondering what > function to use to convert '1e7' to an integer? > >>>> int('1e7') > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > ValueError: invalid literal for int() with base 10: '1e7'
Whenever you use that notation, you always get a float >>> 1e7 10000000.0 So to convert '1e7' to a number, you need to use float('1e7') which you can then convert to an int >>> int(float('1e7')) 10000000 > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list