知识卡片

操作参考卡 · 6276.a

传输编码与字符编码要分层

理解等级:中级

quoted-printable或base64把字节表示成可传输形式,charset再说明这些字节怎样转为文字。示例先统一UTF-8解码再无条件quopri处理,不能涵盖所有MIME类型;应根据Content-Transfer-Encoding先恢复字节,再按部件字符集解码。HTML正文还需另作文本提取,附件与多种替代正文也不能简单全部拼接当独立内容。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 2 处

    • · 查看原书依据

      quopri.decodestring(msg) # Strip out HTML tags, if any are present. # Bail on unknown encodings if errors happen in BeautifulSoup. try: soup = BeautifulSoup(msg) except: return ''

    • · 查看原书依据

      quopri.decodestring(msg) # Strip out HTML tags, if any are present. # Bail on unknown encodings if errors happen in BeautifulSoup. try: soup = BeautifulSoup(msg) except: return ''

    参考来源

    - 位置:《社交网站的数据挖掘与分析(原书第2版)》第6章《6.2.4 将Unix邮箱转换为JSON》(spine102;extracted/OReilly精品图书系列共21册(《Javascript权威指南》、《机器学习:实用案例解析》、《编写可读代码的艺术》、《算法精解》等)/_epub-src/text/part0091.html;u092-ch06-013)。 - 结论依据:原文在“quopri.decodestring”附近的定义、例子或代码支撑本卡核心说明:quoted-printable或base64把字节表示成可传输形式,charset再说明这些字节怎样转为文字。边界按已读前提解释;示例未执行。 - 原始内容:quopri.decodestring(msg) # Strip out HTML tags, if any are present. # Bail on unknown encodings if errors happen in BeautifulSoup. try: soup = BeautifulSoup(msg) except: return '' - 位置:《社交网站的数据挖掘与分析(原书第2版)》第6章《6.5.2 通过IMAP获取和解析邮件》(spine105;extracted/OReilly精品图书系列共21册(《Javascript权威指南》、《机器学习:实用案例解析》、《编写可读代码的艺术》、《算法精解》等)/_epub-src/text/part0094.html;u103-ch06-013)。 - 结论依据:复用旧转换器不会修复其先UTF8再统一quoted-printable的局限。 - 原始内容:quopri.decodestring(msg) # Strip out HTML tags, if any are present. # Bail on unknown encodings if errors happen in BeautifulSoup. try: soup = BeautifulSoup(msg) except: return ''