Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.060 X-Spam-Evidence: '*H*': 0.88; '*S*': 0.00; 'subject:skip:a 10': 0.09; 'subject:How': 0.10; 'python': 0.11; 'subscripted': 0.16; 'discussion': 0.18; '>>>': 0.22; 'import': 0.22; 'header:User- Agent:1': 0.23; '>>>': 0.24; 'idea': 0.28; 'skip:c 30': 0.32; 'subject:with': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'subject:?': 0.36; 'received:10': 0.37; 'message- id:@gmail.com': 0.38; 'auto': 0.38; 'gmail': 0.38; 'to:addr :python-list': 0.38; 'delete': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'how': 0.40; 'account': 0.65; 'email addr:gmail.com.': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type; bh=VxW3RPrajO5e1GZxYTG7a1qHpbqy0xRmOdUJ9MSbPJg=; b=KikibUqlOHNPB3R8+AYzCve90NDgvbdSPfN4o31uN33MzVVj6pqHVVIl0ATWwd4K+/ 85HVYwraaD8GH7OcaS1Cg7VU36woCnEBLQpMM6pJdp7C6B5YIDGzrsCOxVgwOO4WIoZC 1UO4cDt81qA0X/e9G9VPdxV+XNPhNr/L6+Mk8/vmIcg8pjSaNMYJQuvN9+OaAi5eiN5Y lUhP6diaIxDHbobpLoVBAAupam9CucQ3qj1xiReTeYJHKBUORnEa1T88Sa7tyabmwebX HlELTLVBx6hCmFQNkNkcBeoVHhreI7bhAg3vBRflJjMu0bkaMfXj/DFhOvFXNWmWd4B2 Wz5A== X-Received: by 10.70.128.164 with SMTP id np4mr749655pdb.168.1407315758840; Wed, 06 Aug 2014 02:02:38 -0700 (PDT) Date: Wed, 06 Aug 2014 17:02:30 +0800 From: elearn User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-Version: 1.0 To: python-list@python.org Subject: How to delete letters automatically with imaplib? Content-Type: multipart/alternative; boundary="------------020803010905080506000802" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 71 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1407315762 news.xs4all.nl 2844 [2001:888:2000:d::a6]:56648 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:75786 This is a multi-part message in MIME format. --------------020803010905080506000802 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit I have a gmail account 'xxx@gmail.com' which subscripted python maillist. To take part in python discussion is the only target for my xxx@gmail.com. There are so many emails in my xxx@gmail.com,it is a good idea for me to auto delete all emails whose body contain no . I write some codes to do the job. |import imaplib user="xxx" password="yyyyyy" con=imaplib.IMAP4_SSL('imap.gmail.com') con.login(user,password) con.select('INBOX') status, data= con.search(None, "ALL") print(len(data[0].split())) 48 typ, data= con.search(None, 'Body', '"xxx@gmail.com"') >>> data [b'1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 32 33 34 35 36 37 44'] len(data[0].split()) 36| How can i delete 48-36=12 letters? --------------020803010905080506000802 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit

I have a gmail account 'xxx@gmail.com' which subscripted python maillist. To take part in python discussion is the only target for my xxx@gmail.com. There are so many emails in my xxx@gmail.com,it is a good idea for me to auto delete all emails whose body contain no . I write some codes to do the job.

import imaplib
user="xxx"
password="yyyyyy"
con=imaplib.IMAP4_SSL('imap.gmail.com')
con.login(user,password)
con.select('INBOX')
status, data = con.search(None, "ALL")
print(len(data[0].split()))
48
typ, data = con.search(None, 'Body', '"xxx@gmail.com"')
>>> data
[b'1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
 32 33 34 35 36 37 44']

len(data[0].split())
36

How can i delete 48-36=12 letters?

--------------020803010905080506000802--