In an interactive Python session, you type some Python code after the prompt, >>>. The Python interpreter reads and executes what you type, carrying out your various commands.
在一个交互式 Python 会话中,你在提示符 >>> 后输入一些 Python 代码。Python 解释器读取并执行你输入的内容,执行你的各种命令。
To start an interactive session, run the Python 3 application. Type python3 at a terminal prompt (Mac/Unix/Linux) or open the Python 3 application in Windows.
If you see the Python prompt, >>>, then you have successfully started an interactive session. These notes depict example interactions using the prompt, followed by some input.
>>> 2 + 2
4
要启动一个交互式会话,运行Python 3应用程序。在终端提示符下输入 python3 (Mac/Unix/Linux) 或在 Windows 中打开 Python 3 应用程序。 如果你看到 Python 提示符,>>>,那么你已经成功地开始了一个交互式会话。这些说明描述了使用提示符进行交互的例子,后面是一些输入。
Interactive controls. Each session keeps a history of what you have typed. To access that history, press
互动控制。每个会话都有一个你所输入的历史记录。要访问该历史记录,可按<控制>-P(上一个)和<控制>-N(下一个)。
-D退出会话,就会丢掉这个历史记录。在某些系统上,向上和向下的箭头也可以循环查看历史记录。