|
1鱼币
读取邮件怎么才可以不重复读取,备注:因为不确定那个邮箱没办法删除邮件 ,但是每次连接都会重复读取,求助!
附代码:
def main() :
email = 'xxxxx@163.com'
password = 'xxxx'
pop3_server = 'pop.163.com'
p=poplib.POP3_SSL(pop3_server, port = 995)
try:
p.user(email)
p.pass_(password)
except poplib.error_proto as e:
print("hehe")
else:
visit_all_listings(p)
finally:
p.quit
# print("测试")
#显示邮件数目和大小
def visit_all_listings(p) :
respons ,listings ,octets = p.list()
for listing in listings:
visit_listing(p,listing)
#读取没封的几个链接信息
def visit_listing(p,listing):
number ,size = listing.decode('ascii').split()
print("邮件 %s 有 %s byte" %(number,size))
response,lines,octets =p.top(number,0)
document = '\n'.join(line.decode('ascii') for line in lines)
print("aaa1")
message =email.message_from_string(document)
print("aaa")
for header in 'From' , 'TO' ,'Subject' ,'Date':
if header in message:
print(header +':',message[header])
if __name__ == '__main__':
main() |
评分
-
查看全部评分
|