PyDocs

Nav

Internet Data Handling

Message.get_param

  • Message.get_param(param, failobj=None, header='content-type', unquote=True)
Return the parameter value if found in the Content-Type header.

Optional failobj is the object to return if there is no Content-Type
header, or the Content-Type header has no such parameter.  Optional
header is the header to search instead of Content-Type.

Parameter keys are always compared case insensitively.  The return
value can either be a string, or a 3-tuple if the parameter was RFC
2231 encoded.  When it's a 3-tuple, the elements of the value are of
the form (CHARSET, LANGUAGE, VALUE).  Note that both CHARSET and
LANGUAGE can be None, in which case you should consider VALUE to be
encoded in the us-ascii charset.  You can usually ignore LANGUAGE.
The parameter value (either the returned string, or the VALUE item in
the 3-tuple) is always unquoted, unless unquote is set to False.

If your application doesn't care whether the parameter was RFC 2231
encoded, it can turn the return value into a string as follows:

    rawparam = msg.get_param('foo')
    param = email.utils.collapse_rfc2231_value(rawparam)
0 Examples
No examples for email.message/Message.get_param.
See Also
No see-alsos for email.message/Message.get_param
0 Notes
No notes for Message.get_param