小编Dor*_*gel的帖子

与 python 上的交互式 shell 脚本交互

我在 Windows 上有一个交互式 shell 应用程序。我想编写一个 python 脚本,它将向该 shell 应用程序发送命令并读回响应。不过,我想以交互方式执行此操作,即我希望 shell 应用程序随着 python 脚本的运行而继续运行。

我努力了

self.m_process subprocess.Popen(path_to_shell_app,shell=True,stdin=subprocess.PIPE,stdout=subprocess.PIPE,universal_newlines=True)
Run Code Online (Sandbox Code Playgroud)

然后使用 stdin 和 stdout 发送和接收数据。似乎外壳应用程序正在打开,但我无法与其通信。

我究竟做错了什么?

python interactive-shell

5
推荐指数
1
解决办法
5479
查看次数

标签 统计

interactive-shell ×1

python ×1