This function is to convert a string or an integer to a floating-point number. If the parameterxis a string, the number string is used only in decimal notation, which can be preceded by a symbol to represent a positive number, or negative. If the parameterxis an integer that can be converted to a floating-point number representation. However, there is a special place for this function, which is to useInfinityorinfto represent an infinite number. Like+infis a positive infinity,-infis negative infinity. Here we introduce the infinite concept of mathematics, then infinity multiplied by0is equal to what? Here is equal tonan, i.e.Not a number (is not a number).
Example:
#float () Print (float (' 37.21 ')) print (float (234)) Print (float (' +inf ') + 200000) print (float ('-inf ') * 0) print (float (' C5/>-12345\n ') Print (float (' 1e-003 '))
The output results are as follows:
37.21
234.0
Inf
Nan
-12345.0
0.001
Cai Junsheng qq:9073204 Shenzhen
Python standard library: Built-in function float ([x])