I have a list with prices of cars in string ("45.000,00"), I would like to convert this value to float in python.
It looks like this: 45,000.00 in string I want it like this: 45.000.00 in float
I have a list with prices of cars in string ("45.000,00"), I would like to convert this value to float in python.
It looks like this: 45,000.00 in string I want it like this: 45.000.00 in float
Just remove the ',' characters before running through float
.
float("45,000.00".replace(",", ""))
Edit - misread. You want to remove all '.'s, then replace ','s with '.'s.
float("45.000,00".replace(".", "").replace(",", "."))
However this is a bit hard-coded and nasty - a better solution would be to use some locale library for value handling.