How can I parse a numeric string to its corresponding float value?

PythonServer Side ProgrammingProgramming

Python’s number conversion function float() converts an integer to float with fractional part as 0. It also parses a string with valid representation of float number to a float object.

>>> float('1.11')
1.11
>>> float(1)
1.0
>>> float('1')
1.0
>>> float('1.1e-2')
0.011


raja
Published on 08-Feb-2018 19:05:41
Advertisements