Use float() method or decimal() method to convert string to double in Python. Conversion of string to double is the same as the conversion of string to float.
Example convert a string to a double in Python
Simple example code only works on a string with a number or decimal values.
Using float() method
s = "2.367" res = float(s) print(res) print(type(res))
Using decimal() method
from decimal import Decimal s = "2.367" res = Decimal(s) print(res) print(type(res))
Do comment if you have any doubts and suggestions on this Python string double program.
Note: IDE: PyCharm 2021.1.3 (Community Edition)
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.
Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.