Question
Asked By – kevinlu
How can I convert a string like 123,456.908
to float 123456.908
in Python?
For int
s, see How to convert a string to a number if it has commas in it as thousands separators?, although the techniques are essentially the same.
Now we will see solution for issue: How can I convert a string with dot and comma into a float in Python
Answer
Just remove the ,
with replace()
:
float("123,456.908".replace(',',''))
This question is answered By – zeekay
This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0