- 1
How to convert "12.3+13.5" to float in python?
3 Respostas
+ 3
print(f"float= {12.3+13.5})
https://www.sololearn.com/Course/JUMP_LINK__&&__Python__&&__JUMP_LINK-for-Beginners/?ref=app
+ 1
The exec function can execute a string as though it is Python code.
exec("x=" + "12.3+13.5")
print(x)
The numbers in the string can be separated out and then converted from string into float.
x, y = "12.3+13.5".split('+', 1)
print(float(x) + float(y))
0
Please always tag the language you're asking about.
https://code.sololearn.com/W3uiji9X28C1/?ref=app