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控制台实现tab补全和清屏的例子

在shell(bash)下有2个很基本的功能,那就是tab补全,和clear清屏,对于我这种时不时不自觉的就手残要clear清屏一下的人来说,python控制台不能清屏很不爽,经过goo...

win7+Python3.5下scrapy的安装方法

win7+Python3.5下scrapy的安装方法

如何在win7+Python3.5的环境下安装成功scrapy? 通过pip3 install Scrapy直接安装,一般会报错:error: Unable to find vcvars...

python给微信好友定时推送消息的示例

如下所示: from __future__ import unicode_literals from threading import Timer from wxpy import...

python通过ffmgep从视频中抽帧的方法

如下所示: ffmpeg中文文档:http://linux.51yip.com/search/ffmpeg ffmpeg -i test_baofeng.wmv -y -f image2...

python实现自动网页截图并裁剪图片

本文实例为大家分享了python自动网页截图并裁剪图片的具体代码,供大家参考,具体内容如下 代码: # coding=utf-8 import time from selenium...