string to double python code example
Example 1: cast string to double python
x = "2342.34"
float(x) #2342.3400000000001
Example 2: string to float python
# Use the function float() to turn a string into a float
string = '123.456'
number = float(string)
number
# Output:
# 123.456
Example 3: float to int in python
# convert float to int
int(2.0) #output :2