문제

I'm trying to use the data collected by a form I to a sqlite query. In this form I've made a spin button which gets any numeric input (ie. either2,34 or 2.34) and sends it in the form of 2,34 which python sees as str.

I've already tried to float() the value but it doesn't work. It seems to be a locale problem but somehow locale.setlocale(locale.LC_ALL, '') is unsupported (says WinXP). All these happen even though I haven't set anything to greek (language, locale, etc) but somehow Windows does its magic.

Can someone help?

PS: Of course my script starts with # -*- coding: utf-8 -*- so as to have anything in greek (even comments) in the code.

도움이 되었습니까?

해결책

AFAIK, WinXP supports setlocale just fine.

If you want to do locale-aware conversions, try using locale.atof('2,34') instead of float('2,34').

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top