51Testing软件测试论坛

标题: 对于 email.header.Header()这个类的理解有一点疑问,求大佬指教。 [打印本页]

作者: Dreamingboy    时间: 2018-2-1 14:08
标题: 对于 email.header.Header()这个类的理解有一点疑问,求大佬指教。
这是 Header()类:
email.header.Header(s=None, charset=None, maxlinelen=None, header_name=None, continuation_ws=' ', errors='strict')

其中参数的含义理解如下:
s:标头的值,也就是对应 From、To、Subject 的值;
charset:字符集格式,默认是 ASCII,但是一般指定 UTF-8 格式以兼容更多字符;
header_name:标头名,就是 From、To、Subject、Time 等;

我的疑问就是:
1.maxlinelen 参数的含义是什么? 网上查找资料,对这个参数的描述解释是:最大行长度可以通过 maxlinelen 明确指定。为了将第一行拆分为较短的值(以考虑不包括在 s 中的字段报头,例如 Subject )传递 header_name 中的字段的名称。默认的 maxlinelen 是 78。 但是我不太理解,这个第一行是哪一行?还有这个参数对于邮件的具体影响在哪里?

2.continuation_ws 参数默认是空格,这个参数是拆分上面所说的第一行的时候用到的吗,具体是什么作用?

有点罗嗦,在网上实在找不到答案了,希望懂这个 email 模块的大神给点指教。万分感谢!!
作者: Dreamingboy    时间: 2018-2-1 14:35
有没有朋友知道?求指教!
作者: always_fly    时间: 2018-2-2 17:08
email的 header构造方法,根据官网的描述:“The maximum line length can be specified
explicitly via maxlinelen. For splitting the first line to a shorter value (to account for the
field header which isn’t included in s, e.g. Subject) pass in the name of the field in
 header_name. The default maxlinelen is 76, and the default value for header_name
 is None, meaning it is not taken into account for the first line of a long, split header.
应该是在指定 header_name的前提下,限定当前字段(field)值的最大长度,默认长度
限制为76个 ASCII 字符长,通常是用在限制 Subject 的最大长度。





欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2