from datetime import datetime


def fmt_datetime(datestr):
    """
    Reformats a date/time string so that it avoids any special characters.
    :param datestr: a string representing a date/time in 'YYYY-mm-dd HH:MM:SS'
                    or 'YYYY-mm-ddTHH:MM:SS' format
    :returns: a string representing a date/time in 'YYYY-mm-ddTHH-MM-SS' format
    """
    for fmt in ['%Y-%m-%d %H:%M:%S', '%Y-%m-%dT%H:%M:%S']:
        try:
            dt = datetime.strptime(datestr, fmt)
            return dt.strftime('%Y-%m-%dT%H-%M-%S')
        except ValueError:
            pass
    raise ValueError('No valid date format found')