On this page
  1. email.message_from_bytes
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

email.message_from_bytes

Prev: email.message_from_binary_file | Up: email | Next: email.message_from_file
Rel: email.message_from_binary_file, email.message_from_file, email.message_from_string
Ref: docs.python.org — email.message_from_bytes
Tags: #public #python3 #stdlib #email


Import

import email
from email import message_from_bytes

Signature & Overview

email.message_from_bytes(s, *args, **kws)

Parse a bytes string into a Message object model.

Usage

import email
from email import policy

msg = email.message_from_bytes(b"Subject: Test\r\n\r\nHello", policy=policy.default)
assert msg["Subject"] == "Test" and msg.get_content() == "Hello"

Gotchas

REPL Inspect

from email import message_from_bytes
help(message_from_bytes)

Linked from

Related notes