How to get get_body() to work? (about email)
Peng Yu
pengyu.ut at gmail.com
Sat Mar 18 22:49:45 EDT 2023
Hi,
https://docs.python.org/3/library/email.parser.html
It says "For MIME messages, the root object will return True from its
is_multipart() method, and the subparts can be accessed via the
payload manipulation methods, such as get_body(), iter_parts(), and
walk()."
But when I try the following code, get_body() is not found. How to get
get_body() to work?
$ python3 -c 'import email, sys; msg =
email.message_from_string(sys.stdin.read()); print(msg.get_body())'
<<< some_text
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'Message' object has no attribute 'get_body'
--
Regards,
Peng
More information about the Python-list
mailing list