0
我無法讓setlocale工作。 hr_HR應該將逗號識別爲小數點定界符,而不是。我錯過了什麼?我在Ubuntu 14.10上,python 2.7python setlocale不起作用
>>> import locale
>>> float("3.2")
3.2
>>> float("3,2")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid literal for float(): 3,2
>>> locale.setlocale(locale.LC_NUMERIC, 'hr_HR.utf8')
'hr_HR.utf8'
>>> float("3.2")
3.2
>>> float("3,2")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid literal for float(): 3,2
>>> locale.setlocale(locale.LC_ALL, 'hr_HR.utf8')
'hr_HR.utf8'
>>> float("3.2")
3.2
>>> float("3,2")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid literal for float(): 3,2
>>>