Velocity Reviews

Velocity Reviews (
-   Python (
-   -   Re: How convert string '1e7' to an integer? (

MRAB 11-08-2009 01:45 AM

Re: How convert string '1e7' to an integer?
Peng Yu 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'

In Python the e-form indicates a float, as does the presence of a
decimal point, but you can convert to float and then to int:

>>> int(float('1e7'))


All times are GMT. The time now is 04:05 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.