Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/278.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:重定向到带有子进程的多文件描述符_Python_Redirect_Subprocess - Fatal编程技术网

Python:重定向到带有子进程的多文件描述符

Python:重定向到带有子进程的多文件描述符,python,redirect,subprocess,Python,Redirect,Subprocess,如何使用子进程重定向到多个文件描述符?假设在命令行中我使用了python3test.py4>fd4.txt 5>fd5.txt,但我想在子流程中运行它,我该如何做 我知道如果只是重定向到stdout,我可以做如下操作: with open('myfile', "w") as outfile: subprocess.run(my_cmd, stdout=outfile) 但我不知道如何重定向到特定的文件描述符

如何使用子进程重定向到多个文件描述符?假设在命令行中我使用了
python3test.py4>fd4.txt 5>fd5.txt
,但我想在子流程中运行它,我该如何做

我知道如果只是重定向到stdout,我可以做如下操作:

with open('myfile', "w") as outfile:
    subprocess.run(my_cmd, stdout=outfile)
但我不知道如何重定向到特定的文件描述符