from datetime import datetime


def get_datetime_object_from_string(str, datetime_format="%Y-%m-%d%H:%M:%S"):
    """
    Get datetime object from datetime string and format string.
    Args:
        str (): DateTime string : 2022-01-27T14:49:01.125Z
        datetime_format (): Format string to use: "%Y-%m-%dT%H:%M:%S.%f%z"

    Returns: datetime object

    """
    return datetime.strptime(str, datetime_format)