In article <blu176-w10190cb892a0414c988a05d7...@phx.gbl>,
 Carlos Nepomuceno <carlosnepomuc...@outlook.com> wrote:
> Is there a way to format integers with thousands separator (digit grouping) 
> like the format specifier of str.format()?> 
> I'm currently using the following:> 
> >>> sys.stdout.write('Number = %s\n' % '{:,.0f}'.format(x))
> Number = 12,345> 
> 'x' is unsigned integer so it's like using a sledgehammer to crack a nut!> 
> I'd like to have something like:
> sys.stdout.write('Number = %,u\n' % x)
> Is that possible? How can I do it if not already available?                   

For Python 3.2+ or 2.7, why not just:

>>> print('Number = {:,}'.format(x))
Number = 12,345

-- 
 Ned Deily,
 n...@acm.org

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to