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

📄 100.html

📁 国外python经典教材,python爱好者的首选
💻 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 -&gt; Interactive Sessions</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> &gt; <a href="0735710910.html" class="navtitle">Python Essential Reference, Second Edition</a> &gt; <a href="97.html" class="navtitle">10. Execution Environment</a> &gt; <span class="nonavtitle">Interactive Sessions</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="99.html" title="Interpreter Options and Environment"><font size="1">&lt;&nbsp;BACK</font></a></td><td align=center width="70%" class="headingsubbarbg"><font size="1"><a href="popanote.asp?pubui=oreilly&bookname=0735710910&snode=100" target="_blank" title="Make a public or private annnotation">Make Note</a> | <a href="100.html" title="Use a Safari bookmark to remember this section">Bookmark</a></font></td><td align=right width="15%" class="headingsubbarbg"><a href="101.html" title="Launching Python Applications"><font size="1">CONTINUE&nbsp;&gt;</font></a></td></TR></TABLE>
<a href="5%2F28%2F2002+9%3A04%3A01+PM.html" TABINDEX="-1"><img src=images/spacer.gif border=0 width=1 height=1></a><font color=white size=1>155117184014003188065099048180054212144238241179195140058238111161105082191049141199181067</font><a href="read8.asp?bookname=0735710910&snode=100&now=5%2F28%2F2002+9%3A04%3A01+PM" TABINDEX="-1"><img src=images/spacer.gif border=0 width=1 height=1></a><br>
<FONT>
<h3>Interactive Sessions</h3>
<p>If no program name is given and the standard input to the interpreter is an interactive terminal, Python starts in interactive mode. In this mode, a banner message is printed and the user is presented with a prompt. In addition, the interpreter evaluates the script contained in the <tT CLAss="monofont">PYTHONSTARTUP</tt>  environment variable (if set). This script is evaluated as if part of the input program (that is, it isn抰 loaded using an <TT CLass="monofont">import</tT>  statement). One application of this script might be to read a user configuration file such as <TT Class="monofont">.pythonrc</tt>.</p>

<p>When accepting interactive input, two user prompts appear. The <tt class="monofont">&gt;&gt;&gt;</tt> prompt appears at the beginning of a new statement; the <tt cLasS="monofont">...</tt> prompt indicates a statement continuation. For example:</p>

<Pre>

Python 2.0 (#1, Oct 27 2000, 14:34:45) 
[GCC 2.95.2 19991024 (release)] on sunos5 
Type "copyright", "credits" or "license" for more information.. 
&gt;&gt;&gt; for i in range(0,4): 
...     print i 
... 
0 
1 
2 
3 
&gt;&gt;&gt; </prE>

<p>In customized applications, you can change the prompts by modifying the values of <tt CLASs="monofont">sys.ps1</tt>  and <tT CLAss="monofont">sys.ps2</tt>.</P>

<P>On some systems, Python may be compiled to use the GNU readline library. If enabled, this library provides command histories, completion, and other additions to Python抯 interactive mode. The special key bindings provided by the <TT clasS="monofont">readline</TT> library are described in the <A href="112#118.html">readline</a>  module in <a href="105.html">Appendix A</a>.</p>

<p>By default, the output of commands issued in interactive mode is generated by printing the output of the built-in <tt class="monofont">repr()</Tt> function on the result. Starting with Python 2.1, this can be changed by setting the variable <tT claSs="monofont">sys.displayhook</tt>. For example:</p>

<Pre>

&gt;&gt;&gt; def my_display(x): 
...     print "result = %s" % repr(x) 
... 
&gt;&gt;&gt; sys.displayhook = my_display 
&gt;&gt;&gt; 3+4 
result = 7 
&gt;&gt;&gt; </pRE>
</FOnt>
<P><TABLE width="100%" border=0><TR valign="top"><TD><font size=1 color="#C0C0C0"><br></font></TD><TD align=right><font size=1 color="#C0C0C0">Last updated on 3/28/2002<br>Python Essential Reference, Second Edition, &copy;&nbsp;2002 New Riders Publishing</font></TD></TR></TABLE></P>
<TABLE border=0 width="100%" cellspacing=0 cellpadding=0><TR><td align=left width="15%" class="headingsubbarbg"><a href="99.html" title="Interpreter Options and Environment"><font size="1">&lt;&nbsp;BACK</font></a></td><td align=center width="70%" class="headingsubbarbg"><font size="1"><a href="popanote.asp?pubui=oreilly&bookname=0735710910&snode=100" target="_blank" title="Make a public or private annnotation">Make Note</a> | <a href="100.html" title="Use a Safari bookmark to remember this section">Bookmark</a></font></td><td align=right width="15%" class="headingsubbarbg"><a href="101.html" title="Launching Python Applications"><font size="1">CONTINUE&nbsp;&gt;</font></a></td></TR></TABLE>
</TD></TR></TABLE>




<!--EndOfBrowse-->

</TD></TR></TABLE>
<table width=100% border=0 cellspacing=0 cellpadding=0 bgcolor=#990000><tr><td><p align=center><font size=1 face="verdana,arial,helvetica" color=white>

⌨️ 快捷键说明

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