I'm trying to parse this object which comes from a C# DateTime object, then serialized to JSON:
{ "date": "2021-02-18T19:35:19.6472822+01:00", "value": 8, "temp": 7 }
I'm using this in Python to parse it:
from datetime import datetime as dt
date_obj = dt.strptime('2021-02-18T19:35:19.6472822+01:00', '%Y-%m-%dT%H:%M:%S.%f%z')
That Python code works when the decimal places are fewer than 7.
This is the error I get:
Exception <class 'ValueError'> raised: time data '2021-02-18T19:35:19.6472822+01:00'
does not match format '%Y-%m-%dT%H:%M:%S.%f%z'
Is there another way to parse this string in Python?