March 2003
Intermediate to advanced
656 pages
39h 30m
English
format
format(fmt,num,grouping=0)
Returns the string obtained by formatting number
num according to the format string
fmt and the LC_NUMERIC
setting. Except for cultural convention issues, the result is like
fmt
%
num.
If grouping is true,
format also groups digits in the result string
according to the LC_NUMERIC setting. For example:
>>> locale.setlocale(locale.LC_NUMERIC,'en')'English_UnitedStates.1252'>>> locale.format('%s',1000*1000)'1000000'>>> locale.format('%s',1000*1000,1)'1,000,000'
When the numeric locale is U.S. English, and argument
grouping is true,
format supports the convention of grouping digits
by threes with commas.