'%Y' in strftime() vs. strptime()

Eryk Sun eryksun at gmail.com
Sun Dec 29 17:28:48 EST 2019


On 12/29/19, Johannes Bauer <dfnsonfsduifb at gmx.de> wrote:
>
>>>> x = d(1, 1, 1)
>
>>>> x.strftime("%Y-%m-%d")
> '1-01-01'

The default padding depends on the platform strftime. POSIX strftime
[1] supports an extension of ISO C that allows specifying the "0" pad
character and minimum field width, e.g. "%04Y-%02m-%02d".

[1] https://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html


More information about the Python-list mailing list