In Python a float has the following notation: 35.45
. However in Belgium the notation is a bit different: 34,78
. For my thesis it's very important that the floats are printed in the right notation. I could convert every float to a string and change the '.'
to a ','
but I wondered if there was any other solution.
You can use str
function from locale
package:
>>> import locale
>>> locale.setlocale(locale.LC_ALL, "nl_BE")
'nl_BE'
>>> locale.str(234.2)
'234,2'
You can also convert localised string to float:
>>> locale.atof("23424,2")
23424.2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With