from datetime import datetime


def fromisoformat(isoformat):
    """
    Return a datetime from a string in ISO 8601 date time format

    >>> fromisoformat("2019-12-31 23:59:59")
    datetime.datetime(2019, 12, 31, 23, 59, 59)

    """
    try:
        return datetime.fromisoformat(isoformat)  # Python >= 3.7
    except AttributeError:
        return datetime.strptime(isoformat, "%Y-%m-%d %H:%M:%S")