Re: [Tutor] string formatting currency

2006-06-20 Thread Python
On Tue, 2006-06-20 at 13:49 -0400, Paul D. Kraus wrote: > How can i print a float as a currency with commas. > > 1222333.4 -> 1,222,333.40 > > if i '%0.2f'%number > > i get > 1222333.40 import locale >>> locale.setlocale(locale.LC_ALL,"") 'en_US.UTF-8' >>> currency_symbol = locale.localeconv()

Re: [Tutor] string formatting currency

2006-06-20 Thread Kent Johnson
Paul D. Kraus wrote: > How can i print a float as a currency with commas. > > 1222333.4 -> 1,222,333.40 > > if i '%0.2f'%number > > i get > 1222333.40 Use locale.format(): In [1]: import locale In [2]: f=1222333.4 In [6]: locale.setlocale(locale.LC_ALL, "") Out[6]: 'English_United States.125

[Tutor] string formatting currency

2006-06-20 Thread Paul D. Kraus
How can i print a float as a currency with commas.1222333.4 -> 1,222,333.40if i '%0.2f'%numberi get1222333.40Thanks,Paul ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor