mirror of
https://github.com/python/cpython.git
synced 2025-10-09 08:31:26 +00:00
Issue #23511: Port email-simple.py to Python 3.
Also, update email examples to use the context manager version of open(). Patch by Baptiste Mispelon.
This commit is contained in:
parent
b808d590a2
commit
f9e3cf1f9f
4 changed files with 10 additions and 10 deletions
|
@ -1,8 +1,9 @@
|
|||
# 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'))
|
||||
# If the e-mail headers are in a file, uncomment these two lines:
|
||||
# with open(messagefile) as fp:
|
||||
# headers = Parser().parse(fp)
|
||||
|
||||
# Or for parsing headers in a string, use:
|
||||
headers = Parser().parsestr('From: <user@example.com>\n'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue