python - 如何在 Win32 上的 Emacs 中运行交互式命令行 Python 应用程序?

标签 python emacs

如果我使用 M-x shell 并运行交互式 Python 解释器,Windows 上的 Emacs 不会返回任何 IO。

当我发现 M-x python-shell 时,我重拾希望。但是,我不想运行交互式 Python shell,而是想运行一个具有交互式 CLI 的特定 Python 脚本。 (有关详细信息,请参阅 Python 的 cmd 模块)。

有没有办法在 Emacs 中启动交互式 Python 脚本? (标准输出、标准输入、标准错误)

最佳答案

我从这里抓取了一个 cmd 示例:http://www.doughellmann.com/PyMOTW/cmd/index.html

似乎示例中的所有输入行都有一个 (Cmd) 提示 - 不确定是否总是如此。

编辑 python.el 中的 python-shell 定义以包含“(Cmd)”

(setq comint-prompt-regexp "^>>> \\|^[.][.][.] \\|^(pdb) \\|^\\(Cmd\\) ")

重新评估 python-shell 区域,启动 shell 并使用以下命令加载脚本:

>>> 执行文件("script.py")

输入/输出似乎工作...不确定 stderr 或这是否适用于更复杂的脚本。

关于python - 如何在 Win32 上的 Emacs 中运行交互式命令行 Python 应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2860386/

相关文章:

python - Beautiful Soup 类型错误和正则表达式

emacs - Emacs calc 的当前版本在哪里?

python - 使用 Python 语言服务器实现 Atom

python - 在 Python 中散列一个元组,其中顺序很重要?

python - 如何使用 ftplib 在远程服务器上创建 .txt 文件并使用变量在其中放置一些字符串?

emacs - 为什么是 Ctrl+.当我将它绑定(bind)到 Emacs 中的命令时不起作用?

emacs - org-mode下如何导出内部链接?

emacs - 如何在 Emacs 的标记环中前后移动

emacs - 如何在 Emacs 中为自定义次要模式创建键绑定(bind)

python - 自动执行 C 脚本以处理多个文件