def encode_str(string, encoding="utf-8", errors="strict"):
    """Return an encoded byte object of the input string.

    Parameters
    ----------
    string : string
    encoding : string
        Default is `utf-8`.
    errors : string
        Specifies how encoding errors should be handled. Default is `strict`.
    """
    return str(string).encode(encoding=encoding, errors=errors)