This is the standard string representation in datetime:
>>> from datetime import datetime, timezone
>>> dt = datetime(2017, 1, 1, tzinfo=timezone.utc)
>>> print(dt)
2017-01-01 00:00:00+00:00
What is the correct format string for parsing with datetime.strptime? That is, what happens instead of '???' to see the following result:
>>> from dateutil.parser import parse
>>> parse(date_str) == datetime.strptime('???', date_str)
True
source
share