以交互模式调用编辑器 [英] Invoke the editor in the interactive mode

查看:120
本文介绍了以交互模式调用编辑器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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.

这篇关于以交互模式调用编辑器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆