Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 当多个Popen链接时,将字符串馈送到第一个Popen_Python_Pipe_Popen - Fatal编程技术网

Python 当多个Popen链接时,将字符串馈送到第一个Popen

Python 当多个Popen链接时,将字符串馈送到第一个Popen,python,pipe,popen,Python,Pipe,Popen,对于如何使用Popen.communicateintput=将字符串馈送到Popen,有一个答案。然而,我有一个问题,像这样链接几个Popen: p1 = Popen(['fstcompile', '--isymbols=ascii.syms', '--osymbols=ascii.syms'], stdin=PIPE, stdout=PIPE) p2 = Popen(['fstprint', '--isymbols=ascii.syms', '--osymbols=ascii.syms'],

对于如何使用Popen.communicateintput=将字符串馈送到Popen,有一个答案。然而,我有一个问题,像这样链接几个Popen:

p1 = Popen(['fstcompile', '--isymbols=ascii.syms', '--osymbols=ascii.syms'], stdin=PIPE, stdout=PIPE)
p2 = Popen(['fstprint', '--isymbols=ascii.syms', '--osymbols=ascii.syms'], stdin=p1.stdout, stdout=PIPE)
p1.stdout.close()
我想将一个字符串作为stdin提供给p1,然后执行整个序列

我尝试了以下方法:

p1.stdin.write('xxxx')
p1.stdin.flush()
print p2.communicate()[0]
但它不起作用

将字符串放在p2.Communication[0]上没有任何意义,它也无法正常工作

那么在这种情况下应该怎么做呢

先谢谢你