📄 234.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 Developer's Handbook -> Interpreter</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="227.html" class="navtitle">17. Development Tools</a> > <span class="nonavtitle">Interpreter</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="233.html" title="Generating an Executable Python Bytecode"><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=234" target="_blank" title="Make a public or private annnotation">Make Note</a> | <a href="234.html" title="Use a Safari bookmark to remember this section">Bookmark</a></font></td><td align=right width="15%" class="headingsubbarbg"><a href="235.html" title="Debugging the Application"><font size="1">CONTINUE ></font></a></td></TR></TABLE>
<a href="6%2F1%2F2002+6%3A22%3A16+PM.html" TABINDEX="-1"><img src=images/spacer.gif border=0 width=1 height=1></a><font color=white size=1>152015024128143245168232148039196038240039088173205162105045222218066183101016112088125</font><a href="read4.asp?bookname=0672319942&snode=234&now=6%2F1%2F2002+6%3A22%3A16+PM" TABINDEX="-1"><img src=images/spacer.gif border=0 width=1 height=1></a><br>
<FONT>
<h3>Interpreter</h3>
<p>After installing Python, some special environment variables can be configured in order to guarantee the maximum usage of the Python environment. The following list shows some important <a NAME="idx1073750177"></a>
<a naME="idx1073750178"></A>
<A name="idx1073750179"></A>environment variables recognized by the Python interpreter.</P>
<BLockquote>
<p>
<a name="idx1073750180"></a>
<a name="idx1073750181"></A>
<p><tT claSs="monofont">PYTHONPATH</tt>棤
This variable contains a list of directories used by the interpreter, as search path, when importing modules. The best installation strategy is to put extra Python modules in the <tT claSS="monofont">/lib/python$(ver)/site-packages</TT> subdirectory under the root Python installation, so you can tell between standard Python packages and add-ons. Then you just need to set <tt clASS="monofont">PYTHONPATH </Tt>to your Python search path.</p>
</p>
<p>
<A NAMe="idx1073750182"></a>
<a nAME="idx1073750183"></A>
<p><tt class="monofont">PYTHONSTARTUP</tt>棤
This variable contains the name of the directory that must have all its files automatically loaded at the time of starting the Python interpreter.</p>
</p>
<p>
<a name="idx1073750184"></a>
<a NamE="idx1073750185"></a>
<p><tT clasS="monofont">PATH(or path)</tt>棤
This is a system environment variable that contains the directory where the Python interpreter is located.</p>
</P>
<P>
<A Name="idx1073750186"></a>
<A NAMe="idx1073750187"></a>
<a nAME="idx1073750188"></A>
<a namE="idx1073750189"></A>
<P><Tt class="monofont">TCL_LIBRARY, TK_LIBRARY</tt>棤
These variables set the names of the directories where we can find the libraries for both the Tcl and Tk systems. You don't need to set these variables unless you move your Tcl or Tk files after building and installing them (the same as for Python).</p>
</p>
</blockquote>
<P>Each system has a different way to set up these variables. For example, UNIX users running all <i>bourne</i> shell compatible shells, could type</P>
<pre>
PYTHONPATH=".:/usr/local/python/lib"
export PYTHONPATH
</Pre>
<p>On the other hand, Windows and DOS users are familiar with the following syntax:</p>
<Pre>
set PYTHONPATH=.;c:\ python\ lib
</pRE>
<P>The Macintosh people must use the <A name="idx1073750190"></A>
<A NAme="idx1073750191"></a>
<a NAME="idx1073750192"></a>
<a naME="idx1073750193"></A>
<A name="idx1073750194"></a>
<tt class="monofont">EditPythonPrefs</tt> program that comes along with their version of the Python distribution. Note that this application is also used to set up the values for the command line options that are passed to the interpreter.<a name="idx1073750195"></a>
<A naMe="idx1073750196"></a>
<a Name="idx1073750197"></a>
</P>
<p>When your system is able to locate the Python installation, you can <a nAME="idx1073750198"></A>
<a namE="idx1073750199"></A>call the interpreter by typing the command</P>
<Pre>
python
</prE>
<P>invoking the interpreter without arguments, connecting the standard input to a tty device, executing commands interactively.</P>
<Pre>
python filename
</prE>
<P>If you inform a filename, the interpreter tries to read and execute the contents of the file.</P>
<P>The next line shows the general syntax to <a name="idx1073750200"></a>
<a name="idx1073750201"></a>start up the Python interpreter.</p>
<pre>
python [options] [-c cmd | filename | -] [file_arguments]
</pre>
<p>The <A naMe="idx1073750202"></a>
<a Name="idx1073750203"></a>
<A namE="idx1073750204"></A>
<A Name="idx1073750205"></a>command line options in <A HREf="234#1.html">Table 17.5</a> are available on Windows and UNIX systems.</p>
<a NAME="1"></a><p><taBLE Border="1" cellspacing="0" cellPadDing="1" Width="100%">
<CaptION><H5>Table
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -