locale

Convert decimal mark when reading numbers as input

Convert decimal mark when reading numbers as input Question: I have a CSV file with data reading that I want to read into Python. I get lists that contain strings like “2,5”. Now doing float(“2,5”) does not work, because it has the wrong decimal mark. How do I read this into Python as 2.5? Asked …

Total answers: 7

Add 'decimal-mark' thousands separators to a number

Add 'decimal-mark' thousands separators to a number Question: How do I format 1000000 to 1.000.000 in Python? where the ‘.’ is the decimal-mark thousands separator. Asked By: CarlosRibet || Source Answers: I didn’t really understand it; but here is what I understand: You want to convert 1123000 to 1,123,000. You can do that by using …

Total answers: 9

python locale strange error. what's going on here exactly?

python locale strange error. what's going on here exactly? Question: So today I upgraded to bazaar 2.0.2, and I started receiving this message (I’m on snow leopard, btw): bzr: warning: unknown locale: UTF-8 Could not determine what text encoding to use. This error usually means your Python interpreter doesn’t support the locale set by $LANG …

Total answers: 3

Locale date formatting in Python

Locale date formatting in Python Question: How do I get datetime.datetime.now() printed out in the native language? >>> session.deathDate.strftime("%a, %d %b %Y") ‘Fri, 12 Jun 2009′ I’d like to get the same result but in local language. Asked By: Alex || Source Answers: You can just set the locale like in this example: >>> import …

Total answers: 6