The way to Convert String to Double in Python

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

Choice 1 – Convert String to Double utilizing float()#

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

Choice 2 – Convert String to Double utilizing decimal.Decimal()#

from decimal import Decimal

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