Python - convert string to double

0 points
Created by:

Unfortunately, there are no doubles in Python. You can use float that behaves like a double as an alternative solution.

Quick solution:

number = "1.234"
result = float(number)

print(type(result))  # <class 'float'>


from decimal import Decimal

number = "1.234"
result = Decimal(number)

print(type(result))  # <class 'decimal.Decimal'>

See also

Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Python - string (popular problems)

Python - convert string to double
Native Advertising
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂