1. 程式人生 > >【Python】How do I convert a string to a double in Python?

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

Date: 2018.5.30

Method1:

pi = ‘3.1415926’
float(pi)
3.1415926

Method2:

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