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

后端 未结 3 729
走了就别回头了
走了就别回头了 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:45

    The decimal operator might be more in line with what you are looking for:

    >>> from decimal import Decimal
    >>> x = "234243.434"
    >>> print Decimal(x)
    234243.434
    

提交回复
热议问题