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

Date: 2018.5.30


Reference:
https://stackoverflow.com/questions/482410/how-do-i-convert-a-string-to-a-double-in-python

Method1:

pi = ‘3.1415926’
float(pi)
3.1415926

Method2:

from decimal import Decimal
x = “234243.434”
print Decimal(x)
234243.434

posted @ 2018-05-30 18:36  SoaringLee_fighting  阅读(440)  评论(0编辑  收藏  举报