Windows 相当于“/dev/stdin"?

编程入门 行业动态 更新时间:2024-10-09 23:17:57
本文介绍了Windows 相当于“/dev/stdin"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有 Python 代码与只接受文件名的 C++ 库对话.我希望它从标准输入读取.在 Unix 机器上,我可以使用/dev/stdin".我以为我可以在 Windows 上使用特殊的CON"设备,但这更像是/dev/tty,因为echo something | my_program"不起作用.

I have Python code talking to a C++ library which only takes filenames. I want it to read from stdin. On Unix machines I can use "/dev/stdin". I thought I could use the special "CON" device on Windows, but that's more like /dev/tty in that "echo something | my_program" does not work.

在 Windows 下支持管道不是必需的,但现在我很好奇.该操作系统是否有类似文件名/dev/stdin"的内容?

Supporting pipes under Windows isn't essential, but now I'm curious. Is there something like the filename "/dev/stdin" for that OS?

推荐答案

据我所知,没有等效的/dev/stdin.但是,如果您确实需要,您可以创建自己的命名管道 (CreateNamedPipe) 并将名称传递给 C++ 库,使用单独的线程将来自 stdin 的输入提供给命名管道.

To the best of my knowledge there is no equivalent of /dev/stdin. However, if you really needed to you could create your own named pipe (CreateNamedPipe) and pass the name to the C++ library, using a separate thread to feed the input from stdin into the named pipe.

更多推荐

Windows 相当于“/dev/stdin"?

本文发布于:2023-11-26 23:43:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1635688.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:dev   Windows   quot   stdin

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!