Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
6f1e400d
Kaydet (Commit)
6f1e400d
authored
Eyl 27, 2014
tarafından
R David Murray
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge: #18854: make it explicit that is_multipart does not mean 'multipart/xxx'.
üst
10177be4
9cc5fd7b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
17 deletions
+54
-17
email.message.rst
Doc/library/email.message.rst
+54
-17
No files found.
Doc/library/email.message.rst
Dosyayı görüntüle @
6f1e400d
...
@@ -131,7 +131,11 @@ Here are the methods of the :class:`Message` class:
...
@@ -131,7 +131,11 @@ Here are the methods of the :class:`Message` class:
Return ``True`` if the message's payload is a list of sub-\
Return ``True`` if the message's payload is a list of sub-\
:class:`Message` objects, otherwise return ``False``. When
:class:`Message` objects, otherwise return ``False``. When
:meth:`is_multipart` returns ``False``, the payload should be a string object.
:meth:`is_multipart` returns ``False``, the payload should be a string
object. (Note that :meth:`is_multipart` returning ``True`` does not
necessarily mean that "msg.get_content_maintype() == 'multipart'" will
return the ``True``. For example, ``is_multipart`` will return ``True``
when the :class:`Message` is of type ``message/rfc822``.)
.. method:: set_unixfrom(unixfrom)
.. method:: set_unixfrom(unixfrom)
...
@@ -584,23 +588,56 @@ Here are the methods of the :class:`Message` class:
...
@@ -584,23 +588,56 @@ Here are the methods of the :class:`Message` class:
Here's an example that prints the MIME type of every part of a multipart
Here's an example that prints the MIME type of every part of a multipart
message structure:
message structure:
.. testsetup::
.. testsetup::
>>> from email import message_from_binary_file
>>> with open('Lib/test/test_email/data/msg_16.txt', 'rb') as f:
... msg = message_from_binary_file(f)
>>> from email.iterators import _structure
.. doctest::
>>> for part in msg.walk():
... print(part.get_content_type())
multipart/report
text/plain
message/delivery-status
text/plain
text/plain
message/rfc822
text/plain
``walk`` iterates over the subparts of any part where
:meth:`is_multipart` returns ``True``, even though
``msg.get_content_maintype() == 'multipart'`` may return ``False``. We
can see this in our example by making use of the ``_structure`` debug
helper function:
.. doctest::
>>> for part in msg.walk():
... print(part.get_content_maintype() == 'multipart'),
... part.is_multipart())
True True
False False
False True
False False
False False
False True
False False
>>> _structure(msg)
multipart/report
text/plain
message/delivery-status
text/plain
text/plain
message/rfc822
text/plain
Here the ``message`` parts are not ``multiparts``, but they do contain
subparts. ``is_multipart()`` returns ``True`` and ``walk`` descends
into the subparts.
>>> from email import message_from_binary_file
>>> with open('Lib/test/test_email/data/msg_16.txt', 'rb') as f:
... msg = message_from_binary_file(f)
.. doctest::
>>> for part in msg.walk():
... print(part.get_content_type())
multipart/report
text/plain
message/delivery-status
text/plain
text/plain
message/rfc822
text/plain
:class:`Message` objects can also optionally contain two instance attributes,
:class:`Message` objects can also optionally contain two instance attributes,
which can be used when generating the plain text of a MIME message.
which can be used when generating the plain text of a MIME message.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment