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中str.format()详解

1. str.format 的引入 在 Python 中,我们可以使用 + 来连接字符串,在简单情况下这种方式能够很好的工作。但是当我们需要进行复杂的字符串连接时,如果依然使用 + 来...

python实现2014火车票查询代码分享

代码基于Python3.3.3,PyQt5.1.1 复制代码 代码如下:# -*- coding: utf-8 -*-# Python 3.3.3# PyQt 5.1.1import s...

python动态视频下载器的实现方法

python动态视频下载器的实现方法

这里向大家分享一下python爬虫的一些应用,主要是用爬虫配合简单的GUI界面实现视频,音乐和小说的下载器。今天就先介绍如何实现一个动态视频下载器。 爬取电影天堂视频 首先介绍的是py...

Python中if elif else及缩进的使用简述

代码如下所示: scole = input("input your scole:") if scole>90: print("A") elif scole>80:...

Python中GIL的使用详解

1、GIL简介 GIL的全称为Global Interpreter Lock,全局解释器锁。 1.1 GIL设计理念与限制 python的代码执行由python虚拟机(也叫解释器主循...