使用电子邮件包查找电子邮件的总大小 [英] find the total size of an email message using the email package

查看:157
本文介绍了使用电子邮件包查找电子邮件的总大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Python的电子邮件包来分析一些电子邮件。我需要获取电子邮件的总大小,包括附件。有没有办法使用电子邮件包?我收到email.message.Message对象的方式是:

I am using Python's email package to analyze some emails. I need to get the total size of the email, including attachments. Is there a way to do this using the email package? The way I get the email.message.Message object is to do:

msg = email.message_from_file(inf)

我希望找到一个方法,如 msg.getSize()我可以使用。

I was hoping to find a method like msg.getSize() that I could use.

只需使用输入文件的字节大小( inf )?

Would it be correct to just use the byte size of the input file (inf)?

推荐答案

根据Martijn发布的链接,我发现这个解决方案,我认为可能比寻求更好/ tell方法:

Based on the link posted by Martijn, I found this solution, which I think may be better than the seek/tell approach:

os.fstat(inf.fileno()).st_size

这篇关于使用电子邮件包查找电子邮件的总大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆