gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-30 01:24:21 25 4
gpt4 key购买 nike

如果我使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com