Tuesday 15 May 2012

Currency formatting in Python -



Currency formatting in Python -

i looking format number 188518982.18 £188,518,982.18 using python.

how can this?

cheers

see locale module.

this currency (and date) formatting.

>>> import locale >>> locale.setlocale( locale.lc_all, '' ) 'english_united states.1252' >>> locale.currency( 188518982.18 ) '$188518982.18' >>> locale.currency( 188518982.18, grouping=true ) '$188,518,982.18'

python formatting currency

No comments:

Post a Comment