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

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

    Be aware that if your string number contains more than 15 significant digits float(s) will round it.In those cases it is better to use Decimal

    Here is an explanation and some code samples: https://docs.python.org/3/library/sys.html#sys.float_info

提交回复
热议问题