2026/1/13 12:18:28
网站建设
项目流程
莫停之科技windows优化大师,提升关键词排名seo软件,网页设计制作软件,注册公司名称查询网站Python 中的 MIME 与 HTML 处理 1. MIME 处理 MIME(多用途互联网邮件扩展)在邮件处理中起着重要作用。下面是一个将指定源目录下的所有文件打包成适合邮件发送的文件的示例代码:
def pack_mail(source_dir, **headers): Given source_dir, a string that is a path to a…Python 中的 MIME 与 HTML 处理1. MIME 处理MIME(多用途互联网邮件扩展)在邮件处理中起着重要作用。下面是一个将指定源目录下的所有文件打包成适合邮件发送的文件的示例代码:def pack_mail(source_dir, **headers): ''' Given source_dir, a string that is a path to an existing, readable directory, and arbitrary header name/value pairs passed in as named arguments, packs all the files directly under source_dir (assumed to be plain text files) into a mail message returned as a string. ''' msg = email.Message.Message( ) for name, value in headers.iteritems( ): msg[name] = value msg['Content-type'] = 'multipart/mixed' filenames = os.walk(source_dir).next( )[-1] for filename in filenames: m = email.Message.Message( ) m.add_heade