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

📄 module-sgmllib.html

📁 一本很好的python的说明书,适合对python感兴趣的人
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<var>tag</var> argument is the name of the tag converted to lower case, and
the <var>method</var> argument is the bound method which should be used to
support semantic interpretation of the end tag.  If no
<tt class="method">end_<var>tag</var>()</tt> method is defined for the closing element,
this handler is not called.  The base implementation simply calls
<var>method</var>.
</dl>

<P>
<dl><dt><b><a name='l2h-2566'><tt class='method'>handle_data</tt></a></b> (<var>data</var>)
<dd>
This method is called to process arbitrary data.  It is intended to be
overridden by a derived class; the base class implementation does
nothing.
</dl>

<P>
<dl><dt><b><a name='l2h-2567'><tt class='method'>handle_charref</tt></a></b> (<var>ref</var>)
<dd>
This method is called to process a character reference of the form
"<tt class="samp">&amp;#<var>ref</var>;</tt>".  In the base implementation, <var>ref</var> must
be a decimal number in the
range 0-255.  It translates the character to ASCII and calls the
method <tt class="method">handle_data()</tt> with the character as argument.  If
<var>ref</var> is invalid or out of range, the method
<code>unknown_charref(<var>ref</var>)</code> is called to handle the error.  A
subclass must override this method to provide support for named
character entities.
</dl>

<P>
<dl><dt><b><a name='l2h-2568'><tt class='method'>handle_entityref</tt></a></b> (<var>ref</var>)
<dd>
This method is called to process a general entity reference of the
form "<tt class="samp">&amp;<var>ref</var>;</tt>" where <var>ref</var> is an general entity
reference.  It looks for <var>ref</var> in the instance (or class)
variable <tt class="member">entitydefs</tt> which should be a mapping from entity
names to corresponding translations.  If a translation is found, it
calls the method <tt class="method">handle_data()</tt> with the translation;
otherwise, it calls the method <code>unknown_entityref(<var>ref</var>)</code>.
The default <tt class="member">entitydefs</tt> defines translations for
<code>&amp;amp;</code>, <code>&amp;apos</code>, <code>&amp;gt;</code>, <code>&amp;lt;</code>, and
<code>&amp;quot;</code>.
</dl>

<P>
<dl><dt><b><a name='l2h-2569'><tt class='method'>handle_comment</tt></a></b> (<var>comment</var>)
<dd>
This method is called when a comment is encountered.  The
<var>comment</var> argument is a string containing the text between the
"<tt class="samp">&lt;!-</tt>" and "<tt class="samp">-&gt;</tt>" delimiters, but not the delimiters
themselves.  For example, the comment "<tt class="samp">&lt;!-text-&gt;</tt>" will
cause this method to be called with the argument <code>'text'</code>.  The
default method does nothing.
</dl>

<P>
<dl><dt><b><a name='l2h-2570'><tt class='method'>report_unbalanced</tt></a></b> (<var>tag</var>)
<dd>
This method is called when an end tag is found which does not
correspond to any open element.
</dl>

<P>
<dl><dt><b><a name='l2h-2571'><tt class='method'>unknown_starttag</tt></a></b> (<var>tag, attributes</var>)
<dd>
This method is called to process an unknown start tag.  It is intended
to be overridden by a derived class; the base class implementation
does nothing.
</dl>

<P>
<dl><dt><b><a name='l2h-2572'><tt class='method'>unknown_endtag</tt></a></b> (<var>tag</var>)
<dd>
This method is called to process an unknown end tag.  It is intended
to be overridden by a derived class; the base class implementation
does nothing.
</dl>

<P>
<dl><dt><b><a name='l2h-2573'><tt class='method'>unknown_charref</tt></a></b> (<var>ref</var>)
<dd>
This method is called to process unresolvable numeric character
references.  Refer to <tt class="method">handle_charref()</tt> to determine what is
handled by default.  It is intended to be overridden by a derived
class; the base class implementation does nothing.
</dl>

<P>
<dl><dt><b><a name='l2h-2574'><tt class='method'>unknown_entityref</tt></a></b> (<var>ref</var>)
<dd>
This method is called to process an unknown entity reference.  It is
intended to be overridden by a derived class; the base class
implementation does nothing.
</dl>

<P>
Apart from overriding or extending the methods listed above, derived
classes may also define methods of the following form to define
processing of specific tags.  Tag names in the input stream are case
independent; the <var>tag</var> occurring in method names must be in lower
case:

<P>
<dl><dt><b>start_<var>tag</var></b> (<var>attributes</var>)
<dd>
This method is called to process an opening tag <var>tag</var>.  It has
preference over <tt class="method">do_<var>tag</var>()</tt>.  The
<var>attributes</var> argument has the same meaning as described for
<tt class="method">handle_starttag()</tt> above.
</dl>

<P>
<dl><dt><b>do_<var>tag</var></b> (<var>attributes</var>)
<dd>
This method is called to process an opening tag <var>tag</var> that does
not come with a matching closing tag.  The <var>attributes</var> argument
has the same meaning as described for <tt class="method">handle_starttag()</tt> above.
</dl>

<P>
<dl><dt><b>end_<var>tag</var></b> ()
<dd>
This method is called to process a closing tag <var>tag</var>.
</dl>

<P>
Note that the parser maintains a stack of open elements for which no
end tag has been found yet.  Only tags processed by
<tt class="method">start_<var>tag</var>()</tt> are pushed on this stack.  Definition of an
<tt class="method">end_<var>tag</var>()</tt> method is optional for these tags.  For tags
processed by <tt class="method">do_<var>tag</var>()</tt> or by <tt class="method">unknown_tag()</tt>, no
<tt class="method">end_<var>tag</var>()</tt> method must be defined; if defined, it will
not be used.  If both <tt class="method">start_<var>tag</var>()</tt> and
<tt class="method">do_<var>tag</var>()</tt> methods exist for a tag, the
<tt class="method">start_<var>tag</var>()</tt> method takes precedence.

<DIV CLASS="navigation"><p><hr><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="markup.html" tppabs="http://www.python.org/doc/current/lib/markup.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="markup.html" tppabs="http://www.python.org/doc/current/lib/markup.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="module-htmllib.html" tppabs="http://www.python.org/doc/current/lib/module-htmllib.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="markup.html" tppabs="http://www.python.org/doc/current/lib/markup.html">13. Structured Markup Processing</A>
<b class="navlabel">Up:</b> <a class="sectref" href="markup.html" tppabs="http://www.python.org/doc/current/lib/markup.html">13. Structured Markup Processing</A>
<b class="navlabel">Next:</b> <a class="sectref" href="module-htmllib.html" tppabs="http://www.python.org/doc/current/lib/module-htmllib.html">13.2 htmllib  </A>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
<hr>See <i><a href="about.html" tppabs="http://www.python.org/doc/current/lib/about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>

⌨️ 快捷键说明

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