用法:
class email.headerregistry.BaseHeader(name, value)name和value从header_factory调用传递给BaseHeader。任何标头对象的字符串值都是完全解码为 unicode 的value。这个基类定义了以下只读属性:
BaseHeader还提供了以下方法,该方法由电子邮件库代码调用,一般不应由应用程序调用:BaseHeader本身不能用于创建标头对象。它定义了一个协议,每个专用标头与之合作以生成标头对象。具体来说,BaseHeader要求专用类提供一个名为parse的classmethod()。该方法调用如下:parse(string, kwds)kwds是包含一个预初始化键defects的字典。defects是一个空列表。 parse 方法应将任何检测到的缺陷附加到此列表中。返回时,kwds字典must至少包含键decoded和defects的值。decoded应该是标头的字符串值(即完全解码为 unicode 的标头值)。 parse 方法应该假设string可能包含 content-transfer-encoded 部分,但也应该正确处理所有有效的 unicode 字符,以便它可以解析 un-encoded 标头值。BaseHeader的__new__然后创建头实例,并调用其init方法。如果专用类希望设置除BaseHeader本身提供的属性之外的其他属性,则只需要提供init方法。这样的init方法应该如下所示:def init(self, /, *args, **kw): self._myattr = kw.pop('myattr') super().init(*args, **kw)也就是说,应该删除和处理专用类放入
kwds字典的任何额外内容,并将kw(和args)的剩余内容传递给BaseHeaderinit方法。
相关用法
- Python email.headerregistry.DateHeader用法及代码示例
- Python email.header.decode_header用法及代码示例
- Python email.message.Message.walk用法及代码示例
- Python email.message.EmailMessage.add_header用法及代码示例
- Python email.utils.getaddresses用法及代码示例
- Python email.message.EmailMessage.walk用法及代码示例
- Python email.message.Message.add_header用法及代码示例
- Python email.message.Message.as_bytes用法及代码示例
- Python email.message.Message.as_string用法及代码示例
- Python email.iterators._structure用法及代码示例
- Python emoji转text用法及代码示例
- Python numpy matrix empty()用法及代码示例
- Python numpy matrix eye()用法及代码示例
- Python enchant.request_dict()用法及代码示例
- Python eval()用法及代码示例
- Python enum.IntEnum用法及代码示例
- Python math expm1()用法及代码示例
- Python enchant.get_enchant_version()用法及代码示例
- Python enchant.request_pwl_dict()用法及代码示例
- Python eval用法及代码示例
注:本文由纯净天空筛选整理自python.org大神的英文原创作品 email.headerregistry.BaseHeader。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
