Python standard library: built-in functions float ([x]), pythonfloat
This function is used to convert a string or an integer to a floating point number. If the x parameter is a string, only a digit string in decimal format is used. You can add a symbol before the number to represent a positive or negative number. If the x parameter is an integer, it can be converted to a floating point. However, this function uses infinity or inf to represent the number of infinity. For example, if + inf is positive infinity,-inf is negative infinity. The concept of infinity is introduced here. What is the value of "infinity" multiplied by "0? Here is nan, that is, not a number (not a number ).
Example:
# Float () print (float ('37. 21 ') print (float (234) print (float (' + inf ') + 200000) print (float ('-inf ') * 0) print (float ('-12345 \ n') print (float ('1e-003 '))
The output result is as follows:
37.21
234.0
Inf
Nan
-12345.0
0.001
Cai junsheng QQ: 9073204 Shenzhen