How do I translate an ISO 8601 datetime string into a Python datetime object? [duplicate]
问题 This question already has answers here : How do I parse an ISO 8601-formatted date? (26 answers) Closed 5 years ago . I\'m getting a datetime string in a format like \"2009-05-28T16:15:00\" (this is ISO 8601, I believe). One hackish option seems to be to parse the string using time.strptime and passing the first six elements of the tuple into the datetime constructor, like: datetime.datetime(*time.strptime(\"2007-03-04T21:08:12\", \"%Y-%m-%dT%H:%M:%S\")[:6]) I haven\'t been able to find a \