main.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:imap_tools 作者: ikvk 项目源码 文件源码
def get_attachments(self) -> Generator:
        """
        Attachments of the mail message (generator)
        :return: generator of tuple(filename: str, payload: bytes)
        """
        for part in self.obj.walk():
            # multipart/* are just containers
            if part.get_content_maintype() == 'multipart':
                continue
            if part.get('Content-Disposition') is None:
                continue
            filename = part.get_filename()
            if not part.get_filename():
                continue  # this is what happens when Content-Disposition = inline
            filename = self._decode_value(*decode_header(filename)[0])
            payload = part.get_payload(decode=True)
            if not payload:
                continue
            yield filename, payload
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号