How to print an integer with commas; E.g., 3,056,789
Michael Hudson
mwh at python.net
Wed Oct 16 09:37:18 EDT 2002
Richard Bow <donkan7 at yahoo.com> writes:
> Given any integer n, how can I convert str(n) to a string with commas in
> the appropriate places? For example, if n is 3056789, I'd like to convert
> str(3056789) to "3,056,789", for better readability of output.
The locale module may help. Not sure, though -- I suggest you read
it's docs.
Cheers,
M.
--
Sufficiently advanced political correctness is indistinguishable
from irony. -- Erik Naggum
More information about the Python-list
mailing list