⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 module-rfc822.html

📁 一本很好的python的说明书,适合对python感兴趣的人
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>12.2 rfc822 -- Parse RFC 822 mail headers</title>
<META NAME="description" CONTENT="12.2 rfc822 -- Parse RFC 822 mail headers">
<META NAME="keywords" CONTENT="lib">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="STYLESHEET" href="lib.css" tppabs="http://www.python.org/doc/current/lib/lib.css">
<LINK REL="next" href="module-mimetools.html" tppabs="http://www.python.org/doc/current/lib/module-mimetools.html">
<LINK REL="previous" href="module-formatter.html" tppabs="http://www.python.org/doc/current/lib/module-formatter.html">
<LINK REL="up" href="netdata.html" tppabs="http://www.python.org/doc/current/lib/netdata.html">
<LINK REL="next" href="message-objects.html" tppabs="http://www.python.org/doc/current/lib/message-objects.html">
</head>
<body>
<DIV CLASS="navigation"><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="writer-impls.html" tppabs="http://www.python.org/doc/current/lib/writer-impls.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
  alt="Previous Page" width="32"></A></td>
<td><A href="netdata.html" tppabs="http://www.python.org/doc/current/lib/netdata.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
  alt="Up One Level" width="32"></A></td>
<td><A href="message-objects.html" tppabs="http://www.python.org/doc/current/lib/message-objects.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
  alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
  alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
  alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
  alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="writer-impls.html" tppabs="http://www.python.org/doc/current/lib/writer-impls.html">12.1.4 Writer Implementations</A>
<b class="navlabel">Up:</b> <a class="sectref" href="netdata.html" tppabs="http://www.python.org/doc/current/lib/netdata.html">12. Internet Data Handling</A>
<b class="navlabel">Next:</b> <a class="sectref" href="message-objects.html" tppabs="http://www.python.org/doc/current/lib/message-objects.html">12.2.1 Message Objects</A>
<br><hr></DIV>
<!--End of Navigation Panel-->

<H1><A NAME="SECTION0014200000000000000000">
12.2 <tt class="module">rfc822</tt> --
         Parse RFC 822 mail headers</A>
</H1>

<P>


<P>
This module defines a class, <tt class="class">Message</tt>, which represents a
collection of ``email headers'' as defined by the Internet standard
<a class="rfc" name="rfcref-47396"
href="javascript:if(confirm('http://www.ietf.org/rfc/rfc0822.txt  \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want to open it from the server?'))window.location='http://www.ietf.org/rfc/rfc0822.txt'" tppabs="http://www.ietf.org/rfc/rfc0822.txt">RFC 822 <img src="offsite.gif" tppabs="http://www.python.org/doc/current/icons/offsite.gif"
  border='0' class='offsitelink' height='15' width='17' alt='[off-site link]'
  ></a>.  It is used in various contexts, usually to read such
headers from a file.  This module also defines a helper class 
<tt class="class">AddressList</tt> for parsing <a class="rfc" name="rfcref-47398"
href="javascript:if(confirm('http://www.ietf.org/rfc/rfc0822.txt  \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want to open it from the server?'))window.location='http://www.ietf.org/rfc/rfc0822.txt'" tppabs="http://www.ietf.org/rfc/rfc0822.txt">RFC 822 <img src="offsite.gif" tppabs="http://www.python.org/doc/current/icons/offsite.gif"
  border='0' class='offsitelink' height='15' width='17' alt='[off-site link]'
  ></a> addresses.  Please refer to
the RFC for information on the specific syntax of <a class="rfc" name="rfcref-47400"
href="javascript:if(confirm('http://www.ietf.org/rfc/rfc0822.txt  \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want to open it from the server?'))window.location='http://www.ietf.org/rfc/rfc0822.txt'" tppabs="http://www.ietf.org/rfc/rfc0822.txt">RFC 822 <img src="offsite.gif" tppabs="http://www.python.org/doc/current/icons/offsite.gif"
  border='0' class='offsitelink' height='15' width='17' alt='[off-site link]'
  ></a> headers.

<P>
The <tt class='module'><a href="module-mailbox.html" tppabs="http://www.python.org/doc/current/lib/module-mailbox.html">mailbox</a></tt> module provides classes 
to read mailboxes produced by various end-user mail programs.

<P>
<dl><dt><b><a name='l2h-2346'><tt class='class'>Message</tt></a></b> (<var>file</var><big>[</big><var>, seekable</var><big>]</big>)
<dd>
A <tt class="class">Message</tt> instance is instantiated with an input object as
parameter.  Message relies only on the input object having a
<tt class="method">readline()</tt> method; in particular, ordinary file objects
qualify.  Instantiation reads headers from the input object up to a
delimiter line (normally a blank line) and stores them in the
instance.

<P>
This class can work with any input object that supports a
<tt class="method">readline()</tt> method.  If the input object has seek and tell
capability, the <tt class="method">rewindbody()</tt> method will work; also, illegal
lines will be pushed back onto the input stream.  If the input object
lacks seek but has an <tt class="method">unread()</tt> method that can push back a
line of input, <tt class="class">Message</tt> will use that to push back illegal
lines.  Thus this class can be used to parse messages coming from a
buffered stream.

<P>
The optional <var>seekable</var> argument is provided as a workaround for
certain stdio libraries in which <tt class="cfunction">tell()</tt> discards buffered
data before discovering that the <tt class="cfunction">lseek()</tt> system call
doesn't work.  For maximum portability, you should set the seekable
argument to zero to prevent that initial <tt class="method">tell()</tt> when passing
in an unseekable object such as a a file object created from a socket
object.

<P>
Input lines as read from the file may either be terminated by CR-LF or
by a single linefeed; a terminating CR-LF is replaced by a single
linefeed before the line is stored.

<P>
All header matching is done independent of upper or lower case;
e.g. <code><var>m</var>['From']</code>, <code><var>m</var>['from']</code> and
<code><var>m</var>['FROM']</code> all yield the same result.
</dl>

<P>
<dl><dt><b><a name='l2h-2347'><tt class='class'>AddressList</tt></a></b> (<var>field</var>)
<dd>
You may instantiate the <tt class="class">AddressList</tt> helper class using a single
string parameter, a comma-separated list of <a class="rfc" name="rfcref-47403"
href="javascript:if(confirm('http://www.ietf.org/rfc/rfc0822.txt  \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want to open it from the server?'))window.location='http://www.ietf.org/rfc/rfc0822.txt'" tppabs="http://www.ietf.org/rfc/rfc0822.txt">RFC 822 <img src="offsite.gif" tppabs="http://www.python.org/doc/current/icons/offsite.gif"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -