Python Datetime Strptime Error: '-' is a bad directive in format '%-m-%-d-%y %-H:%M:%S'

前端 未结 1 457
暗喜
暗喜 2020-12-16 16:58

I know that there have been similar questions asked, but they seemed to have to do with the way datetime deals (or doesn\'t deal) with timezones.

The setup is a litt

相关标签:
1条回答
  • 2020-12-16 17:25

    %-* -- to skip padding -- is a GNU libc extension. It's not part of POSIX strftime, and thus not guaranteed to be portable to systems where your time-formatting calls aren't eventually backed by GNU's strftime C library function.

    The Python datetime module documentation explicitly specifies the format strings it supports, and this extension is not given. Thus, while this is supported in GNU date and GNU strftime(), it isn't available in Python datetime.

    0 讨论(0)
提交回复
热议问题