← 返回首页
Documentation: Error in datetime.datetime.strptime() · Issue #94300 · python/cpython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

Documentation: Error in datetime.datetime.strptime() #94300

New issue
New issue

Description

Documentation

The documentation for datetime.datetime.strptime is incorrect:

This is equivalent to::
datetime(*(time.strptime(date_string, format)[0:6]))

This is incorrect if format contains microseconds or timezone information. Counterexample:

>>> timestr = '20200304050607.554321' >>> print(datetime.strptime(timestr, '%Y%m%d%H%M%S.%f')) 2020-03-04 05:06:07.554321 >>> print(datetime(*(time.strptime(timestr, '%Y%m%d%H%M%S.%f')[0:6]))) 2020-03-04 05:06:07

I suggest removing the cited part entirely, since since I see no easy way of correcting these lines, especially concerning timezones.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    • Open in GitHub Copilot app

    Footer

    © 2026 GitHub, Inc.