Jupyter 简明教程
IPython - Importing Python Shell Code
IPython 可以从带有默认 >>> 提示符的标准 Python 控制台和另一个 IPython 会话中读取内容。以下屏幕截图显示在标准 Python shell 中编写的 for 循环 −
IPython can read from standard Python console with default >>> prompt and another IPython session. The following screenshot shows a for loop written in standard Python shell −
复制代码(连同 Python 提示符),并将其粘贴到 IPython 输入单元格中。IPython 会智能地滤出输入提示符 (>>> 和 …) 或 IPython 提示符 (In [N]: 和 …:)
Copy the code (along with Python prompt) and paste the same in IPython input cell. IPython intelligently filters out the input prompts (>>> and …) or IPython ones (In [N]: and …:)
同样,来自一个 IPython 会话的代码也可以粘贴到另一个会话中。下面给出的第一个屏幕截图显示在一个 IPython 窗口中定义 SayHello() 函数 −
Similarly, code from one IPython session can be pasted in another. The first screenshot given below shows definition of SayHello() function in one IPython window −
现在,让我们选择代码并粘贴到另一个 IPython shell 中并调用 SayHello() 函数。
Now, let us select the code and paste in another IPython shell and call SayHello() function.