python – Convert string real brazilian to float

python – Convert string real brazilian to 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.

python – Convert string real brazilian to float

Leave a Reply

Your email address will not be published. Required fields are marked *