Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #7188
| Date | 2011-06-07 23:36 +0200 |
|---|---|
| Subject | Dynamic Zero Padding. |
| From | Friedrich Clausen <fred@derf.nl> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1.1307482621.11593.python-list@python.org> (permalink) |
Hello All,
I want to print some integers in a zero padded fashion, eg. :
>>> print("Testing %04i" % 1)
Testing 0001
but the padding needs to be dynamic eg. sometimes %05i, %02i or some
other padding amount. But I can't insert a variable into the format
specification to achieve the desirable padding.
I would be much obliged if someone can give me some tips on how to
achieve a variably pad a number.
Cheers,
Fred.
Thanks,
Fred.
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Dynamic Zero Padding. Friedrich Clausen <fred@derf.nl> - 2011-06-07 23:36 +0200
Re: Dynamic Zero Padding. Mel <mwilson@the-wire.com> - 2011-06-07 17:43 -0400
Re: Dynamic Zero Padding. Chris Angelico <rosuav@gmail.com> - 2011-06-08 09:26 +1000
Re: Dynamic Zero Padding. Terry Reedy <tjreedy@udel.edu> - 2011-06-07 22:56 -0400
Re: Dynamic Zero Padding. Friedrich Clausen <fred@derf.nl> - 2011-06-08 09:00 +0200
Re: Dynamic Zero Padding. harrismh777 <harrismh777@charter.net> - 2011-06-07 16:55 -0500
csiph-web