How to Convert String to Double in Python

If you need to convert a String to a Double in your Python code:

Option 1 – Convert String to Double using float()

string = '1234.5678'
myfloat = float(string)
print(myfloat)

Option 2 – Convert String to Double using decimal.Decimal()

from decimal import Decimal

string = '1234.5678'
myfloat = Decimal(string)
print(myfloat)