New submission from v kats :
Section "strftime() and strptime() Behavior" says:
"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."
It implies that this applies for strftime only, and indeed it refers to C
library’s strftime().
However, it's easy to miss (at least I got confused and lost some time), so I
propose to clarify the paragraph.
strptime and %s
# python
Python 2.7.6 (default, Nov 23 2017, 15:49:48)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import datetime
>>> datetime.strptime('1532689414','%s')
Traceback (most recent call last):
File "", line 1, in
strftime and %s
python
Python 2.7.6 (default, Nov 23 2017, 15:49:48)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import datetime
>>> datetime.now().strftime('%s')
'1532702817'
File "/usr/lib/python2.7/_strptime.py", line 317, in _strptime
(bad_directive, format))
ValueError: 's' is a bad directive in format '%s'
--
assignee: docs@python
components: Documentation
messages: 322498
nosy: docs@python, v kats
priority: normal
severity: normal
status: open
title: Full set of format codes applies to strftime only
type: enhancement
versions: Python 2.7
___
Python tracker
<https://bugs.python.org/issue34249>
___
___
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com