I want to fill out a string with spaces. I know that the following works for zero\'s:
>>> print \"\'%06d\'\"%4 \'000004\'
But wha
A nice trick to use in place of the various print formats:
(1) Pad with spaces to the right:
('hi' + ' ')[:8]
(2) Pad with leading zeros on the left:
('0000' + str(2))[-4:]