📄 140.html
字号:
<!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 Essential Reference, Second Edition -> Python 2.0</TITLE>
<LINK REL="stylesheet" HREF="oreillyi/oreillyM.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="2.html" class="navtitle">Linux/Unix</a> > <a href="0735710910.html" class="navtitle">Python Essential Reference, Second Edition</a> > <a href="137.html" class="navtitle">C. Summary of Changes</a> > <span class="nonavtitle">Python 2.0</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="139.html" title="Python 1.6"><font size="1">< BACK</font></a></td><td align=center width="70%" class="headingsubbarbg"><font size="1"><a href="popanote.asp?pubui=oreilly&bookname=0735710910&snode=140" target="_blank" title="Make a public or private annnotation">Make Note</a> | <a href="140.html" title="Use a Safari bookmark to remember this section">Bookmark</a></font></td><td align=right width="15%" class="headingsubbarbg"><a href="141.html" title="Python 2.1"><font size="1">CONTINUE ></font></a></td></TR></TABLE>
<a href="5%2F28%2F2002+9%3A11%3A36+PM.html" TABINDEX="-1"><img src=images/spacer.gif border=0 width=1 height=1></a><font color=white size=1>155117184014003188065099048180054212144238241179195140058238111161104059122182070167086172</font><a href="read7.asp?bookname=0735710910&snode=140&now=5%2F28%2F2002+9%3A11%3A36+PM" TABINDEX="-1"><img src=images/spacer.gif border=0 width=1 height=1></a><br>
<FONT>
<h3>Python 2.0</h3>
<ul>
<LI>
<P>Unicode support.</P>
</li>
<li>
<P>List comprehensions.</P>
</LI>
<li>
<p>Augmented assignment operators (<tT CLAss="monofont">+=</tt>, <tt class="monofont">-=</tt>, <tt class="monofont">*=</Tt>, <tT claSs="monofont">/=</tt>, <tT claSS="monofont">%=</TT>, <tt clASS="monofont">**=</Tt>, <tt cLASS="monofont">&=</tt>, <tt CLASs="monofont">|=</tt>, <tt class="monofont">^=</tt>, <tt class="monofont">>>=</tT>, and <tt ClasS="monofont"><<=</tt>) and associated special methods <tt ClasS="monofont">_ _iadd_ _</TT>, <Tt claSS="monofont">_ _isub_ _</TT>, etc.</p>
</li>
<lI>
<P>The syntax <I><Tt claSS="monofont">f</TT></i>
<tt class="monofont">(*</tt><i><tt class="monofont">args</tt></I>
<tt ClasS="monofont">,**</tt><i><tT claSS="monofont">kwargs</TT></i>
<tt cLASS="monofont">)</tt> can now be used to call a function with positional arguments <i><tT CLAss="monofont">args</tt></I>
and keyword arguments <I><TT class="monofont">kwargs</tt></i>
. Previously, the built-in <tt class="monofont">apply()</tt> function was used for this purpose.</p>
</li>
<Li>
<p>Garbage collection of cyclical data structures and the <Tt clAss="monofont">gc</tt> module.</P>
</li>
<lI>
<P>Enhanced <TT clasS="monofont">print</TT> statement. <Tt claSS="monofont">print >></TT><i><tt cLASS="monofont">f</tt></i>
<tt class="monofont">, </tt><i><tt class="monofont">obj</Tt></i>
now redirects its output to the file object <I><tt cLass="monofont">f</tT></i>
.</p>
</lI>
<LI>
<P>The <tt clASS="monofont">import</Tt> statement has been enhanced with the <tt cLASS="monofont">as</tt> modifier; for example, <tt CLASs="monofont">import foo as bar</tt>. However, <tt class="monofont">as</tt> is not a new Python reserved word.</p>
</li>
<li>
<p>String methods added to both standard and Unicode strings. These methods replace most of the functionality in the <tt ClaSs="monofont">string</tt> module.</P>
</li>
<li>
<P><i><tt CLASs="monofont">d</tt></i>
<TT CLass="monofont">.setdefault()</tT> method added to dictionaries.</P>
</LI>
<li>
<p>New built-in functions: <tT CLAss="monofont">zip()</tt>, <tt class="monofont">unichr()</tt>, <tt class="monofont">unicode()</Tt>.</p>
</Li>
<li>
<P>New modules described in <a hreF="105.html">Appendix A</a>, 揟he Python Library
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -