python 标准输入 eof

发布于 2024-08-10 14:41:20 字数 258 浏览 4 评论 0原文

如何将 python eof 传递到 stdin

这是我的代码,

p = Popen(commd,stdout=PIPE,stderr=PIPE,stdin=PIPE)
o = p.communicate(inputstring)[0]

当我输入输入字符串后在命令行中运行 commd 时,窗口仍然期望 Ctrl+Z 完成接受输入。

如何在程序中传递 eof 或 Ctrl+Z?

谢谢!

How to pass python eof to stdin

here is my code

p = Popen(commd,stdout=PIPE,stderr=PIPE,stdin=PIPE)
o = p.communicate(inputstring)[0]

when i run the commd in command line after i input the inputstring windows still expecting a Ctrl+Z to finish accepting input.

How can I pass eof or Ctrl+Z in program?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光沙漏 2024-08-17 14:41:20
p.stdin.close()

p.communicate之后,完成输入并将EOF发送到commd。

p.stdin.close()

after p.communicate, finishes the input and sends EOF to commd.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文