How do I convert a string to a double in Python?

后端 未结 3 727
走了就别回头了
走了就别回头了 2020-12-12 23:19

I would like to know how to convert a string containing digits to a double.

3条回答
  •  青春惊慌失措
    2020-12-12 23:37

    >>> x = "2342.34"
    >>> float(x)
    2342.3400000000001
    

    There you go. Use float (which behaves like and has the same precision as a C,C++, or Java double).

提交回复
热议问题