Python atof with local input

后端 未结 1 864
小鲜肉
小鲜肉 2021-01-22 01:03

Say, I have a (German) expression which reads 10.401,40 (in Mio EUR), I\'d like to convert this to a real float (in this case around 10 billions) in Python.
Thi

相关标签:
1条回答
  • 2021-01-22 01:38

    I got the same ValueError. As this similar question explains, you need to have the German locale installed in your system. Following the above, I typed in sudo dpkg-reconfigure locales and selected de-DE.UTF-8. I had to modify the locale setting line to match with locale.setlocale(locale.LC_ALL, 'de_DE.utf8') and got your snippet to run. Good luck!

    0 讨论(0)
提交回复
热议问题