On SO question 904928 (Python strftime - date without leading 0?) Ryan answered:
Actually I had the same problem and I realised that, if you add a h
Python datetime.strftime() delegates to C strftime() function that is platform-dependent:
The full set of format codes supported varies across platforms, because Python calls the platform C library’s strftime() function, and platform variations are common. To see the full set of format codes supported on your platform, consult the strftime(3) documentation.
Glibc notes for strftime(3):
- (dash) Do not pad a numeric result string.
The result on my Ubuntu machine:
>>> from datetime import datetime
>>> datetime.now().strftime('%d')
'07'
>>> datetime.now().strftime('%-d')
'7'