知识卡片

普通读书笔记卡 · 6274.d

邮件正文按MIME结构解释

理解等级:中级

简单例子假定单部分邮件,取walk的第一项和payload可处理该虚构输入;多部分时第一项可能是容器,payload也可能是子消息列表。提取正文需区分容器、文本、附件与替代版本,再按传输编码和字符集处理,不能把一个取首项的函数当任意邮箱完整解析器。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 2 处

    • · 查看原书依据

      part.get_payload() return o_msg # Create an mbox that can be iterated over and transform each of its # messages to a convenient JSON representation mbox = mailbox.UnixMailbox(open(

    • · 查看原书依据

      get_content_maintype() == 'multipart': continue json_part['contentType'] = part.get_content_type() content = part.get_payload(decode=False).decode('utf-8', 'ignore') json_part['con

    参考来源

    - 位置:《社交网站的数据挖掘与分析(原书第2版)》第6章《6.2.1 Unix邮箱指南》(spine102;extracted/OReilly精品图书系列共21册(《Javascript权威指南》、《机器学习:实用案例解析》、《编写可读代码的艺术》、《算法精解》等)/_epub-src/text/part0091.html;u089-ch06-005)。 - 结论依据:原文在“part.get_payload()”附近的定义、例子或代码支撑本卡核心说明:简单例子假定单部分邮件,取walk的第一项和payload可处理该虚构输入;多部分时第一项可能是容器,payload也可能是子消息列表。边界按已读前提解释;示例未执行。 - 原始内容:part.get_payload() return o_msg # Create an mbox that can be iterated over and transform each of its # messages to a convenient JSON representation mbox = mailbox.UnixMailbox(open( - 位置:《社交网站的数据挖掘与分析(原书第2版)》第6章《6.2.4 将Unix邮箱转换为JSON》(spine102;extracted/OReilly精品图书系列共21册(《Javascript权威指南》、《机器学习:实用案例解析》、《编写可读代码的艺术》、《算法精解》等)/_epub-src/text/part0091.html;u092-ch06-005)。 - 结论依据:只跳过maintype=multipart未涵盖所有含子消息的容器,需按实际结构与附件语义处理。 - 原始内容:get_content_maintype() == 'multipart': continue json_part['contentType'] = part.get_content_type() content = part.get_payload(decode=False).decode('utf-8', 'ignore') json_part['con