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

📄 module-exceptions.html

📁 一本很好的python的说明书,适合对python感兴趣的人
💻 HTML
📖 第 1 页 / 共 2 页
字号:
  plain integer, <tt class="exception">TypeError</tt> is raised.)
</dl>

<P>
<dl><dt><b><a name='l2h-122'><tt class='exception'>KeyError</tt></a></b>
<dd>
Raised when a mapping (dictionary) key is not found in the set of
  existing keys.
</dl>

<P>
<dl><dt><b><a name='l2h-123'><tt class='exception'>KeyboardInterrupt</tt></a></b>
<dd>
  Raised when the user hits the interrupt key (normally
  <kbd>Control-C</kbd> or <kbd>DEL</kbd>).  During execution, a check for
  interrupts is made regularly.
Interrupts typed when a built-in function <tt class="function">input()</tt> or
  <tt class="function">raw_input()</tt>) is waiting for input also raise this
  exception.
</dl>

<P>
<dl><dt><b><a name='l2h-124'><tt class='exception'>MemoryError</tt></a></b>
<dd>
  Raised when an operation runs out of memory but the situation may
  still be rescued (by deleting some objects).  The associated value is
  a string indicating what kind of (internal) operation ran out of memory.
  Note that because of the underlying memory management architecture
  (C's <tt class="cfunction">malloc()</tt> function), the interpreter may not
  always be able to completely recover from this situation; it
  nevertheless raises an exception so that a stack traceback can be
  printed, in case a run-away program was the cause.
</dl>

<P>
<dl><dt><b><a name='l2h-125'><tt class='exception'>NameError</tt></a></b>
<dd>
  Raised when a local or global name is not found.  This applies only
  to unqualified names.  The associated value is the name that could
  not be found.
</dl>

<P>
<dl><dt><b><a name='l2h-126'><tt class='exception'>NotImplementedError</tt></a></b>
<dd>
  This exception is derived from <tt class="exception">RuntimeError</tt>.  In user
  defined base classes, abstract methods should raise this exception
  when they require derived classes to override the method.
  
New in version 1.5.2.

</dl>

<P>
<dl><dt><b><a name='l2h-127'><tt class='exception'>OSError</tt></a></b>
<dd>
  This class is derived from <tt class="exception">EnvironmentError</tt> and is used
  primarily as the <tt class='module'><a href="module-os.html" tppabs="http://www.python.org/doc/current/lib/module-os.html">os</a></tt> module's <code>os.error</code> exception.
  See <tt class="exception">EnvironmentError</tt> above for a description of the
  possible associated values.
  
New in version 1.5.2.

</dl>

<P>
<dl><dt><b><a name='l2h-128'><tt class='exception'>OverflowError</tt></a></b>
<dd>
Raised when the result of an arithmetic operation is too large to be
  represented.  This cannot occur for long integers (which would rather
  raise <tt class="exception">MemoryError</tt> than give up).  Because of the lack of
  standardization of floating point exception handling in C, most
  floating point operations also aren't checked.  For plain integers,
  all operations that can overflow are checked except left shift, where
  typical applications prefer to drop bits than raise an exception.
</dl>

<P>
<dl><dt><b><a name='l2h-129'><tt class='exception'>RuntimeError</tt></a></b>
<dd>
  Raised when an error is detected that doesn't fall in any of the
  other categories.  The associated value is a string indicating what
  precisely went wrong.  (This exception is mostly a relic from a
  previous version of the interpreter; it is not used very much any
  more.)
</dl>

<P>
<dl><dt><b><a name='l2h-130'><tt class='exception'>SyntaxError</tt></a></b>
<dd>
Raised when the parser encounters a syntax error.  This may occur in
  an <tt class="keyword">import</tt> statement, in an <tt class="keyword">exec</tt> statement, in a call
  to the built-in function <tt class="function">eval()</tt> or <tt class="function">input()</tt>, or
  when reading the initial script or standard input (also
  interactively).

<P>
When class exceptions are used, instances of this class have
atttributes <tt class="member">filename</tt>, <tt class="member">lineno</tt>, <tt class="member">offset</tt> and
<tt class="member">text</tt> for easier access to the details; for string exceptions,
the associated value is usually a tuple of the form
<code>(message, (filename, lineno, offset, text))</code>.
For class exceptions, <tt class="function">str()</tt> returns only the message.
</dl>

<P>
<dl><dt><b><a name='l2h-131'><tt class='exception'>SystemError</tt></a></b>
<dd>
  Raised when the interpreter finds an internal error, but the
  situation does not look so serious to cause it to abandon all hope.
  The associated value is a string indicating what went wrong (in
  low-level terms).

<P>
You should report this to the author or maintainer of your Python
  interpreter.  Be sure to report the version string of the Python
  interpreter (<code>sys.version</code>; it is also printed at the start of an
  interactive Python session), the exact error message (the exception's
  associated value) and if possible the source of the program that
  triggered the error.
</dl>

<P>
<dl><dt><b><a name='l2h-132'><tt class='exception'>SystemExit</tt></a></b>
<dd>
This exception is raised by the <tt class="function">sys.exit()</tt> function.  When it
  is not handled, the Python interpreter exits; no stack traceback is
  printed.  If the associated value is a plain integer, it specifies the
  system exit status (passed to C's <tt class="cfunction">exit()</tt> function); if it is
  <code>None</code>, the exit status is zero; if it has another type (such as
  a string), the object's value is printed and the exit status is one.

<P>
Instances have an attribute <tt class="member">code</tt> which is set to the
  proposed exit status or error message (defaulting to <code>None</code>).
  Also, this exception derives directly from <tt class="exception">Exception</tt> and
  not <tt class="exception">StandardError</tt>, since it is not technically an error.

<P>
A call to <tt class="function">sys.exit()</tt> is translated into an exception so that
  clean-up handlers (<tt class="keyword">finally</tt> clauses of <tt class="keyword">try</tt> statements)
  can be executed, and so that a debugger can execute a script without
  running the risk of losing control.  The <tt class="function">os._exit()</tt> function
  can be used if it is absolutely positively necessary to exit
  immediately (e.g., after a <tt class="function">fork()</tt> in the child process).
</dl>

<P>
<dl><dt><b><a name='l2h-133'><tt class='exception'>TypeError</tt></a></b>
<dd>
  Raised when a built-in operation or function is applied to an object
  of inappropriate type.  The associated value is a string giving
  details about the type mismatch.
</dl>

<P>
<dl><dt><b><a name='l2h-134'><tt class='exception'>UnboundLocalError</tt></a></b>
<dd>
  Raised when a reference is made to a local variable in a function or
  method, but no value has been bound to that variable.  This is a
  subclass of <tt class="exception">NameError</tt>.

New in version 2.0.

</dl>

<P>
<dl><dt><b><a name='l2h-135'><tt class='exception'>UnicodeError</tt></a></b>
<dd>
  Raised when a Unicode-related encoding or decoding error occurs.  It
  is a subclass of <tt class="exception">ValueError</tt>.

New in version 2.0.

</dl>

<P>
<dl><dt><b><a name='l2h-136'><tt class='exception'>ValueError</tt></a></b>
<dd>
  Raised when a built-in operation or function receives an argument
  that has the right type but an inappropriate value, and the
  situation is not described by a more precise exception such as
  <tt class="exception">IndexError</tt>.
</dl>

<P>
<dl><dt><b><a name='l2h-137'><tt class='exception'>WindowsError</tt></a></b>
<dd>
  Raised when a Windows-specific error occurs or when the error number
  does not correspond to an <tt class="cdata">errno</tt> value.  The
  <tt class="member">errno</tt> and <tt class="member">strerror</tt> values are created from the
  return values of the <tt class="cfunction">GetLastError()</tt> and
  <tt class="cfunction">FormatMessage()</tt> functions from the Windows Platform API.
  This is a subclass of <tt class="exception">OSError</tt>.

New in version 2.0.

</dl>

<P>
<dl><dt><b><a name='l2h-138'><tt class='exception'>ZeroDivisionError</tt></a></b>
<dd>
  Raised when the second argument of a division or modulo operation is
  zero.  The associated value is a string indicating the type of the
  operands and the operation.
</dl>

<DIV CLASS="navigation"><p><hr><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="specialattrs.html" tppabs="http://www.python.org/doc/current/lib/specialattrs.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="builtin.html" tppabs="http://www.python.org/doc/current/lib/builtin.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="built-in-funcs.html" tppabs="http://www.python.org/doc/current/lib/built-in-funcs.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="specialattrs.html" tppabs="http://www.python.org/doc/current/lib/specialattrs.html">2.1.8 Special Attributes</A>
<b class="navlabel">Up:</b> <a class="sectref" href="builtin.html" tppabs="http://www.python.org/doc/current/lib/builtin.html">2. Built-in Types, Exceptions</A>
<b class="navlabel">Next:</b> <a class="sectref" href="built-in-funcs.html" tppabs="http://www.python.org/doc/current/lib/built-in-funcs.html">2.3 Built-in Functions</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 + -