python通过imaplib模块读取gmail里邮件的方法

yipeiwu_com6年前Python基础

本文实例讲述了python通过imaplib模块读取gmail里邮件的方法。分享给大家供大家参考。具体实现方法如下:

import imaplib
mailserver = imaplib.IMAP4_SSL('imap.gmail.com', 993)
username = 'gmailusername'
password = 'gmailpassword'
mailserver.login(username, password)
status, count = mailserver.select('Inbox')
status, data = mailserver.fetch(count[0], '(UID BODY[TEXT])')
print data[0][1]
mailserver.close()
mailserver.logout()

希望本文所述对大家的Python程序设计有所帮助。

相关文章

python实现简单登陆流程的方法

python实现简单登陆流程的方法

登陆流程图: 代码实现: #-*- coding=utf-8 -*- import os,sys,getpass ''' user.txt 格式 账号 密码 是否锁定 错误次数 j...

Python concurrent.futures模块使用实例

这篇文章主要介绍了Python concurrent.futures模块使用实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 con...

Python函数的返回值、匿名函数lambda、filter函数、map函数、reduce函数用法实例分析

Python函数的返回值、匿名函数lambda、filter函数、map函数、reduce函数用法实例分析

本文实例讲述了Python函数的返回值、匿名函数lambda、filter函数、map函数、reduce函数用法。分享给大家供大家参考,具体如下: 函数的返回值: 函数一旦执行到&...

python 实现目录复制的三种小结

复制目录: 包含多层子目录 方法: 递归, 深度遍历,广度遍历 深度遍历&广度遍历: 思路: 1.获得源目录子级目录,并设置目标目录的子级路径 1.1在此就创建两个栈(或者队列),将原目...

Django的HttpRequest和HttpResponse对象详解

本文研究的主要是Django的HttpRequest和HttpResponse对象的相关内容,具体如下。 请求一张页面时,Django把请求的metadata数据包装成一个HttpReq...