简体   繁体   中英

Convert scientific notation string into int

How would I convert:

s='8.833167174e+11' (str)
==> 883316717400 (int)

I tried doing int(s) or some other 'casting' but it wasn't effective.

As your string is a float digit you need to first convert it to float :

>>> int(float(s))
883316717400

float([x])

Return a floating point number constructed from a number or string x.

If the argument is a string, it must contain a possibly signed decimal or floating point number, possibly embedded in whitespace. The argument may also be [+|-]nan or [+|-]inf. Otherwise, the argument may be a plain or long integer or a floating point number, and a floating point number with the same value (within Python's floating point precision) is returned. If no argument is given, returns 0.0.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM