I am facing a issue while converting a iso format datetime string to datetime object in Python 3.6 without loosing the timezone info. The string is like this.
2021-07-04T00:00:00+02:00
I tried datetime.datetime.strptime method. But unable to set the correct format string.
datetime.datetime.strptime( "2021-07-04T00:00:00+02:00", "%Y-%m-%dT%H:%M:%S%z")
If the datetime string is in this format it works:
datetime.strptime("2021-07-04T00:00:00+0200", "%Y-%m-%dT%H:%M:%S%z")
But in this format, don't work:
datetime.datetime.strptime( "2021-07-04T00:00:00+02:00", "%Y-%m-%dT%H:%M:%S%z")
And I have the datetime in this format:
2021-07-04T00:00:00+02:00