How to convert a timezone aware string to datetime in Python without dateutil?

StackOverflow

I have to convert a timezone-aware string like "2012-11-01T04:16:13-04:00" to a Python datetime object.

I saw the dateutil module which has a parse function, but I don"t really want to use it as it adds a dependency.

So how can I do it? I have tried something like the following, but with no luck.

datetime.datetime.strptime("2012-11-01T04:16:13-04:00", "%Y-%m-%dT%H:%M:%S%Z")




Get Solution for free from DataCamp guru