I am parsing email with Python 3.2. I want to divide each email in a list file by email to a header list and a body list. What do you think about this method? You were almost there In addition, you can do this with an understanding of the list (more pack):
DEP DPAP (self): #head header body separates from #heads = []; Self.bodies = [] email.readlines () for self.inbox.dex: "" "The first 20 rows enclosed in the main list" "self.heads.append (email [: 10])" "" The remaining body list The line added in "self.bodies.append (Email [10:])
self.inbox.dex is a list of files - Object
... Self.inbox for email. Dex: email = email.readlines () ...
Data = (email ([: 10], email [10:]) in email (x.readlines () self X inbox.dex) self.heads, self.bodies = zip (* data)
No comments:
Post a Comment