In Python 3.5
, I'd like to convert a German number string to a float using locale.atof
with the following code:
import locale
from locale import atof
locale.setlocale(locale.LC_ALL, 'de_DE')
number = atof('17.907,08')
However, this raises a ValueError
:
ValueError: could not convert string to float: '17.907.08'
Why? Isn't this exactly what
atof()
was made for?