94.html
来自「Python Ebook Python&XML」· HTML 代码 · 共 27 行
HTML
27 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Robots" content="INDEX,NOFOLLOW">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<TITLE>Safari | Python Developer's Handbook -> Standard Exceptions (Getting Help from Other Modules)</TITLE>
<LINK REL="stylesheet" HREF="oreillyi/oreillyN.css">
</HEAD>
<BODY bgcolor="white" text="black" link="#990000" vlink="#990000" alink="#990000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" cellpadding=5 cellspacing=0 border=0 class="navtopbg"><tr><td><font size="1"><p class="navtitle"><a href="8.html" class="navtitle">Web Development</a> > <a href="0672319942.html" class="navtitle">Python Developer's Handbook</a> > <a href="91.html" class="navtitle">4. Exception Handling</a> > <span class="nonavtitle">Standard Exceptions (Getting Help from Other Modules)</span></p></font></td><td align="right" valign="top" nowrap><font size="1"><a href="main.asp?list" class="safnavoff">See All Titles</a></font></td></tr></table>
<TABLE width=100% bgcolor=white border=0 cellspacing=0 cellpadding=5><TR><TD>
<TABLE border=0 width="100%" cellspacing=0 cellpadding=0><TR><td align=left width="15%" class="headingsubbarbg"><a href="93.html" title="Exception Handling"><font size="1">< BACK</font></a></td><td align=center width="70%" class="headingsubbarbg"><font size="1"><a href="popanote.asp?pubui=oreilly&bookname=0672319942&snode=94" target="_blank" title="Make a public or private annnotation">Make Note</a> | <a href="94.html" title="Use a Safari bookmark to remember this section">Bookmark</a></font></td><td align=right width="15%" class="headingsubbarbg"><a href="95.html" title="Raising Exceptions"><font size="1">CONTINUE ></font></a></td></TR></TABLE>
<a href="5%2F31%2F2002+4%3A31%3A49+PM.html" TABINDEX="-1"><img src=images/spacer.gif border=0 width=1 height=1></a><font color=white size=1>152015024128143245168232148039199167010047123209178152124239215162147037129069022086011090</font><a href="read3.asp?bookname=0672319942&snode=94&now=5%2F31%2F2002+4%3A31%3A49+PM" TABINDEX="-1"><img src=images/spacer.gif border=0 width=1 height=1></a><br>
<FONT><h3>Standard Exceptions (Getting Help from Other Modules)</h3>
<p>Apart from the <tT CLAss="monofont">exception</tt> module, other Python modules offer you some advanced functionality to handle exceptions. We will talk about the <A NAMe="idx1073743098"></a><a nAME="idx1073743099"></A><tt class="monofont">sys</tt> and the <a name="idx1073743100"></a><a name="idx1073743101"></A><tt ClasS="monofont">traceback</tt> modules.</p>
<p>You can use the <Tt clASS="monofont">sys.exc_info()</Tt> thread-safe function to get information about the current exception being handled. This function returns a tuple of values that is equivalent to the values provided by three other <i><a nAME="idx1073743102"></A><a namE="idx1073743103"></A><A Name="idx1073743104"></a><A NAMe="idx1073743105"></a></i><i><tt class="monofont">sys module</tt></i> objects:</p>
<blockQuoTe>
<p><p><A name="idx1073743106"></A><a naME="idx1073743107"></A>sys.exc_type桼eturns the exception type</P>
</p>
<p><p><a NAME="idx1073743108"></a><a naME="idx1073743109"></A>sys.exc_value桼eturns the exception value</P>
</p>
<p><p><a NAME="idx1073743110"></a><a name="idx1073743111"></a><tt class="monofont">sys.exc_traceback
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?