mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
*Borrow* GNU docs wording
This commit is contained in:
parent
c149570fb1
commit
998e4e8f3d
1 changed files with 5 additions and 8 deletions
|
|
@ -2465,6 +2465,11 @@ These methods accept format codes that can be used to parse and format dates::
|
|||
>>> _.strftime('%a %d %b %Y, %I:%M%p')
|
||||
'Mon 31 Jan 2022, 11:59PM'
|
||||
|
||||
The user has to make sure, though, that the input can be parsed in a unambiguous
|
||||
way. The string ``2025112`` can be parsed using the format ``%Y%m%d`` as ``2025-1-12``,
|
||||
``2025-11-2``, or even ``20251-1-2``. It is necessary to add appropriate separators to
|
||||
reliably get results.
|
||||
|
||||
The following is a list of all the format codes that the 1989 C standard
|
||||
requires, and these work on all platforms with a standard C implementation.
|
||||
|
||||
|
|
@ -2599,14 +2604,6 @@ method. The ISO 8601 year and ISO 8601 week directives are not interchangeable
|
|||
with the year and week number directives above. Calling :meth:`~.datetime.strptime` with
|
||||
incomplete or ambiguous ISO 8601 directives will raise a :exc:`ValueError`.
|
||||
|
||||
.. Note::
|
||||
Input will be split to cope with the provided directives in the format string,
|
||||
this aligns with the behaviour of the C implementation.::
|
||||
|
||||
>>> datetime.strptime('20250310T12','%Y%m%dT%H%M')
|
||||
datetime.datetime(2025, 3, 10, 1, 2)
|
||||
|
||||
|
||||
The full set of format codes supported varies across platforms, because Python
|
||||
calls the platform C library's :c:func:`strftime` function, and platform
|
||||
variations are common. To see the full set of format codes supported on your
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue