我有 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"?
发布评论