Python How to convert String to float
By:Roy.LiuLast updated:2019-08-11
In Python, we can use float() to convert String to float.
num = "3.1415" print(num) print(type(num)) # str pi = float(num) # convert str to float print(pi) print(type(pi)) # float
Output
3.1415 <class 'str'> 3.1415 <class 'float'>
References
From:一号门
COMMENTS