我之前曾问过一个问题,该问题是如何设置tkinter gui来从子流程中接收行,而不会挂起整个程序。现在可以正常工作了。
现在,我不知道如何将新行发送到子流程。我尝试使用process.communicate,但是我可能一直使用不正确。我也尝试了此问题的解决方案,但self.process.stdin.write('stop\n'.encode())
似乎没有用。如何将新命令发送到子python子进程?
相关代码:
self.process = subprocess.Popen([ "python", "-u", dir + "start.py" ],
stdout=subprocess.PIPE,
stdin=subprocess.PIPE,
stderr=subprocess.PIPE,
cwd=dir)
数据可能卡在管道中。self.process.stdin.flush()
写后添加。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句