Skip to content

Commit 2e3e76e

Browse files
gh-57095: Add note about input splitting in datetime.*.strptime (GH-131049)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
1 parent 51a408e commit 2e3e76e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Doc/library/datetime.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2689,6 +2689,12 @@ For the :meth:`.datetime.strptime` and :meth:`.date.strptime` class methods,
26892689
the default value is ``1900-01-01T00:00:00.000``: any components not specified
26902690
in the format string will be pulled from the default value.
26912691

2692+
.. note::
2693+
Format strings without separators can be ambiguous for parsing. For
2694+
example, with ``%Y%m%d``, the string ``2026111`` may be parsed either as
2695+
``2026-11-01`` or as ``2026-01-11``.
2696+
Use separators to ensure the input is parsed as intended.
2697+
26922698
.. note::
26932699
When used to parse partial dates lacking a year, :meth:`.datetime.strptime`
26942700
and :meth:`.date.strptime` will raise when encountering February 29 because

0 commit comments

Comments
 (0)