正如您声称对编程不熟悉一样,我的最佳建议是:始终阅读文档。在
也许你应该先读一个tutorial。在import getpass, imaplib
M = imaplib.IMAP4()
M.login(getpass.getuser(), getpass.getpass())
M.select()
typ, data = M.search(None, 'ALL')
for num in data[0].split():
typ, data = M.fetch(num, '(RFC822)')
print 'Message %s\n%s\n' % (num, data[0][3])
M.close()
M.logout()
你试过了吗?在
关于您的代码:
当您定义^{} loop时,它应该如下所示:
^{pr2}$
x是一个变量,一次保存一个项的值(并且只能在for循环体中访问(有一个例外,但这在这里并不重要)。在
您所做的与imaplib模块无关,只是语法错误。在
顺便说一句,.select()选择一个邮箱,只返回邮箱中的邮件数。一、 e.只是一个标量值,没有序列可以迭代:IMAP4.select([mailbox[, readonly]])
Select a mailbox. Returned data is the count of messages in mailbox (EXISTS response). The default mailbox is 'INBOX'. If the readonly flag is set, modifications to the mailbox are not allowed.
(这确实与imaplib模块有关;)