以交互模式调用编辑器
在Ipython中打开编辑器时,我通常会发出命令
When open an editor within Ipython, I usually issue commands
In [13]: subprocess.run('vim Person.py', shell=True)
Out[13]: CompletedProcess(args='vim Person.py', returncode=0)
如何以直接方式进行?
%edit
magic命令是IPython提供的规范方式。它调用由 $ EDITOR
指定的编辑器,可选择加载指定的文件,并在关闭后执行代码。
The %edit
magic command is the canonical way offered by IPython. It invokes an editor specified by $EDITOR
, optionally loading a specified file, and executes the code after it's closed.
另一个常见的工作流程是让编辑器和控制台在不同的窗口中打开,并在两者之间进行复制粘贴(%粘贴
魔法在这里很方便)。
Another common workflow is to have editor and console open in different windows and copy-paste between the two (the %paste
magic is handy here).
Jupyter Notebook 似乎提供经验类似于MATLAB控制台,虽然我没有任何经验。
Jupyter Notebook seems to offer experience similar to MATLAB console though I don't have any experience with it.