Mercurial > cpython-lru_cache-weakref
view Doc/includes/email-headers.py @ 80661:94de77bd0b4b 2.7
Issue #16194: document imp.load_dynamic problems
when read several extension modules from the same binary object file.
| author | Andrew Svetlov <andrew.svetlov@gmail.com> |
|---|---|
| date | Thu, 29 Nov 2012 19:51:28 +0200 |
| parents | a5f796fb61a1 |
| children | 74d81a3a0d56 |
line wrap: on
line source
# Import the email modules we'll need from email.parser import Parser # If the e-mail headers are in a file, uncomment this line: #headers = Parser().parse(open(messagefile, 'r')) # Or for parsing headers in a string, use: headers = Parser().parsestr('From: <user@example.com>\n' 'To: <someone_else@example.com>\n' 'Subject: Test message\n' '\n' 'Body would go here\n') # Now the header items can be accessed as a dictionary: print 'To: %s' % headers['to'] print 'From: %s' % headers['from'] print 'Subject: %s' % headers['subject']
