当前位置: 首页>>代码示例>>Python>>正文


Python Post.attachments方法代码示例

本文整理汇总了Python中post.Post.attachments方法的典型用法代码示例。如果您正苦于以下问题:Python Post.attachments方法的具体用法?Python Post.attachments怎么用?Python Post.attachments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在post.Post的用法示例。


在下文中一共展示了Post.attachments方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: receive

# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import attachments [as 别名]
 def receive(self, message):
     post = Post()
     html_bodies = message.bodies('text/html')
     img_links = []
     video_links = []
     for content_type, body in html_bodies:
         decoded_body = body.decode()
         img_links.extend(self.find_image_links(decoded_body))
         video_links.extend(self.find_video_links(decoded_body))
 
     if hasattr(message, "attachments") and message.attachments:
         post.attachments = []
         for attachment in message.attachments:
             post.attachments.append(db.Blob(attachment[1].decode()))
 
     plaintext_bodies = message.bodies('text/plain')
     allBodies = '';
     for body in plaintext_bodies:
         allBodies = allBodies + body[1].decode()
 
     if hasattr(message, "subject"):
         subject, encoding = decode_header(message.subject)[0]
         post.caption = unicode(subject)
     post.author = message.sender
     post.content = allBodies
     post.images = img_links
     post.videos = video_links
     post.source = "email"
     post.put()
开发者ID:sephiria,项目名称:sandbox,代码行数:31,代码来源:handle_kitten_mail.py


注:本文中的post.Post.attachments方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。