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.
Advertisement
Answer
Just remove the ,
with replace()
:
float("123,456.908".replace(',',''))