在python中下载主题为lin的附件

2024-10-01 15:32:00 发布

您现在位置:Python中文网/ 问答频道 /正文

import getpass, poplib, email, parse
from poplib  import POP3
user = 'rnandipati@qwerty.com' 
M = poplib.POP3_SSL('outlook.office365.com', '995') 
M.user(user) 
M.pass_('R7!')
numMessages = len(M.list()[1])
print ("You have %d messages." % (numMessages))
print ("Message List:")

M.quit()

我有上面的代码,它给出了我电子邮件中的邮件数量。我想从主题行有“hello”的邮件中下载附件。在

我所做的:

^{pr2}$

我在网上看了很多例子,真的需要帮助。我也是这种脚本的新手。在

谢谢。在


Tags: fromimportcomsslparseemail邮件print
1条回答
网友
1楼 · 发布于 2024-10-01 15:32:00

引用文件:

POP3.retr(which)

Retrieve whole message number which, and set its seen flag. Result is in form (response, ['line', ...], octets).

所以M.retr(mList+1)[1]是一个行列表。在

您正在迭代字符串列表,可以是unicode ou字节字符串。在

文档中没有太多关于字符串类型的说明,但是,如果您使用的是python3,我假设它是unicode字符串。在

所以:msg.startswith("Subject:")应该可以。在

相关问题 更多 >

    热门问题