d = datetime.datetime.strptime('2017-10-13T10:53:53.000Z',
    '%Y-%m-%dT%H:%M:%S.000Z')
with MongoClient() as mongo:
    db = mongo.get_database('test')
How to insert datetime string into Mongodb as ISODate using pymongo