Python subprocess interaction, why does my process work with Popen.communicate, but not Popen.stdout.read()?

前端 未结 2 663
抹茶落季
抹茶落季 2020-12-31 22:56

I am trying to communicate with a command-line chat bot with Python using the subprocess module. (http://howie.sourceforge.net/ using the compiled win32 binary,

2条回答
  •  醉话见心
    2020-12-31 23:54

    If you want to interact with the program after sending the EOF, rather than using Popen.stdin.close(), you can manually send the command-line End Of File character, which has the same effect but leaves stdin open.

    In Python this character's escape sequence is '\x1a'.

提交回复
热议问题