Please put me out of my misery. The following example seems to be using y twice rather than y and then m.
>>> m=8
>>> y=11
>>> print '20{0:02d}{0:02d}01'.format(y, m)
20111101
I've been through as much of the documentation as I can but can't figure out what would have been relatively straightforward with the old procedure:
>>> print '20%02d%02d01' % ( y, m )
20110801
If someone could explain where I'm going wrong I'd be really grateful.
This will do what you want:
print '20{0:02d}{1:02d}01'.format(y, m)
You referred to the first argument twice.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With