/usr/share/doc/diveintopython-zh/html/installing_python/shell.html is in diveintopython-zh 5.4b-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | <!DOCTYPE html
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>1.8. 使用 Python 的交互 Shell</title>
<link rel="stylesheet" href="../diveintopython.css" type="text/css">
<link rev="made" href="mailto:f8dy@diveintopython.org">
<meta name="generator" content="DocBook XSL Stylesheets V1.52.2">
<meta name="keywords" content="Python, Dive Into Python, tutorial, object-oriented, programming, documentation, book, free">
<meta name="description" content="Python from novice to pro">
<link rel="home" href="../toc/index.html" title="Dive Into Python">
<link rel="up" href="index.html" title="第 1 章 安装 Python">
<link rel="previous" href="source.html" title="1.7. 从源代码安装 Python ">
<link rel="next" href="summary.html" title="1.9. 小结">
</head>
<body>
<table id="Header" width="100%" border="0" cellpadding="0" cellspacing="0" summary="">
<tr>
<td id="breadcrumb" colspan="5" align="left" valign="top">导航:<a href="../index.html">起始页</a> > <a href="../toc/index.html">Dive Into Python</a> > <a href="index.html">安装 Python</a> > <span class="thispage">使用 Python 的交互 Shell</span></td>
<td id="navigation" align="right" valign="top"> <a href="source.html" title="上一页: “从源代码安装 Python ”"><<</a> <a href="summary.html" title="下一页: “小结”">>></a></td>
</tr>
<tr>
<td colspan="3" id="logocontainer">
<h1 id="logo"><a href="../index.html" accesskey="1">深入 Python :Dive Into Python 中文版</a></h1>
<p id="tagline">Python 从新手到专家 [Dip_5.4b_CPyUG_Release]</p>
</td>
<td colspan="3" align="right">
<form id="search" method="GET" action="http://www.google.com/custom">
<p><label for="q" accesskey="4">Find: </label><input type="text" id="q" name="q" size="20" maxlength="255" value=""> <input type="submit" value="搜索"><input type="hidden" name="domains" value="woodpecker.org.cn"><input type="hidden" name="sitesearch" value="www.woodpecker.org.cn/diveintopython"></p>
</form>
</td>
</tr>
</table>
<!--#include virtual="/inc/ads" -->
<div class="section" lang="zh_cn">
<div class="titlepage">
<div>
<div>
<h2 class="title"><a name="install.shell"></a>1.8. 使用 <span class="application">Python</span> 的交互 Shell
</h2>
</div>
</div>
<div></div>
</div>
<div class="abstract">
<p>既然我们已经安装了 <span class="application">Python</span>,那么我们运行的这个交互shell是什么东西呢?
</p>
</div>
<p><span class="application">Python</span> 扮演着两种角色。首先它是一个脚本解释器,可以从命令行运行脚本,也可以在脚本上双击,像运行其他应用程序一样。它还是一个交互 shell,可以执行任意的语句和表达式。这一点对调试、快速组建和测试相当有用。我甚至知道一些人把 <span class="application">Python</span> 的交互 shell 当作计算器来使用!
</p>
<p>在您的计算机平台上启动 <span class="application">Python</span> 的交互 shell,接下来让我们尝试着做些操作:
</p>
<div class="example"><a name="d0e3948"></a><h3 class="title">例 1.5. 初次使用交互 Shell</h3><pre class="screen">
<tt class="prompt">>>> </tt><span class="userinput">1 + 1</span> <a name="install.shell.1.1"></a><img src="../images/callouts/1.png" alt="1" border="0" width="12" height="12">
<span class="computeroutput">2</span>
<tt class="prompt">>>> </tt><span class="userinput"><span class='pykeyword'>print</span> <span class='pystring'>'hello world'</span></span> <a name="install.shell.1.2"></a><img src="../images/callouts/2.png" alt="2" border="0" width="12" height="12">
<span class="computeroutput">hello world</span>
<tt class="prompt">>>> </tt><span class="userinput">x = 1</span> <a name="install.shell.1.3"></a><img src="../images/callouts/3.png" alt="3" border="0" width="12" height="12">
<tt class="prompt">>>> </tt><span class="userinput">y = 2</span>
<tt class="prompt">>>> </tt><span class="userinput">x + y</span>
<span class="computeroutput">3</span>
</pre><div class="calloutlist">
<table border="0" summary="Callout list">
<tr>
<td width="12" valign="top" align="left"><a href="#install.shell.1.1"><img src="../images/callouts/1.png" alt="1" border="0" width="12" height="12"></a>
</td>
<td valign="top" align="left"><span class="application">Python</span> 的交互 shell 可以计算任意的 <span class="application">Python</span> 表达式,包括任何基本的数学表达式。
</td>
</tr>
<tr>
<td width="12" valign="top" align="left"><a href="#install.shell.1.2"><img src="../images/callouts/2.png" alt="2" border="0" width="12" height="12"></a>
</td>
<td valign="top" align="left">交互 shell 可以执行任意的 <span class="application">Python</span> 语句,包括 <span><b class="command">print</b></span> 语句。
</td>
</tr>
<tr>
<td width="12" valign="top" align="left"><a href="#install.shell.1.3"><img src="../images/callouts/3.png" alt="3" border="0" width="12" height="12"></a>
</td>
<td valign="top" align="left">也可以给变量赋值,并且变量值在 shell 打开时一直有效 (一旦关毕交互 Sheel,变量值将丢失)。</td>
</tr>
</table>
</div>
</div>
</div>
<table class="Footer" width="100%" border="0" cellpadding="0" cellspacing="0" summary="">
<tr>
<td width="35%" align="left"><br><a class="NavigationArrow" href="source.html"><< 从源代码安装 Python </a></td>
<td width="30%" align="center"><br> <span class="divider">|</span> <a href="index.html#install.choosing" title="1.1. 哪一种 Python 适合您?">1</a> <span class="divider">|</span> <a href="windows.html" title="1.2. Windows 上的 Python">2</a> <span class="divider">|</span> <a href="macosx.html" title="1.3. Mac OS X 上的 Python ">3</a> <span class="divider">|</span> <a href="macos9.html" title="1.4. Mac OS 9 上的 Python ">4</a> <span class="divider">|</span> <a href="redhat.html" title="1.5. RedHat Linux 上的 Python ">5</a> <span class="divider">|</span> <a href="debian.html" title="1.6. Debian GNU/Linux 上的 Python ">6</a> <span class="divider">|</span> <a href="source.html" title="1.7. 从源代码安装 Python ">7</a> <span class="divider">|</span> <span class="thispage">8</span> <span class="divider">|</span> <a href="summary.html" title="1.9. 小结">9</a> <span class="divider">|</span>
</td>
<td width="35%" align="right"><br><a class="NavigationArrow" href="summary.html">小结 >></a></td>
</tr>
<tr>
<td colspan="3"><br></td>
</tr>
</table>
<div class="Footer">
<p class="copyright">Copyright © 2000, 2001, 2002, 2003, 2004 <a href="mailto:mark@diveintopython.org">Mark Pilgrim</a></p>
<p class="copyright">Copyright © 2001, 2002, 2003, 2004, 2005, 2006, 2007 <a href="mailto:python-cn@googlegroups.com">CPyUG (邮件列表)</a></p>
</div>
</body>
</html>
|