How to convert String into Float?

This question already has an answer here:

  • How do I parse a string to a float or int in Python? 22 answers

  • Your line should be pi_float = float(pi_string)

    float(pi_string) is a float value, you can not assign to it, because it is not a variable.


    如果pi_string = "3.1415926" float()方法将为您执行此操作。

    >>>pi_float = float(pi_string)
    >>>type(pi_float)
    <class 'float'>
    
    链接地址: http://www.djcxy.com/p/48422.html

    上一篇: F#字符串到int的转换

    下一篇: 如何将字符串转换为浮点型?