Python读取指定日期邮件
背景:9月份有部分数据缺失,这部分数据在邮箱里,需要重新拉取,但是每天几百封邮件,总共有6、7万封邮件,使用stat()和retr(which)结合遍历很 耗时 基于如上背景,初始大致思路为: 使用二分法获取到需要恢复数据时间范围内的中间一个值,也就是第几封邮件,然后分两头遍历, 读取到所有需要的邮件 算法函数: 1、获取到邮件的时间,由于可能收到格林威治时间邮件,所以这里做了相应的处理 [python]view plain copy defgetTimeStamp(cn): messages=mailServer.retr(cn)[1] mail=email.message_from_bytes('\n'.encode('utf-8').join(messages)) date=email.header.decode_header(mail.get('date')) utcstr=date[0][0].replace('+00:00','') globalutcdatetime try: utcdatetime=datetime.datetime.strptime(utcstr,...







