子进程。打开尝试写入不存在的管道
原学程将引见子过程。翻开测验考试写进没有存留的管讲的处置办法,这篇学程是从其余处所瞅到的,而后减了1些海外法式员的疑问与解问,愿望能对于您有所赞助,佳了,上面开端进修吧。
成绩描写
为何以下选项没有起感化?
import subprocess
process = subprocess.Popen('cmd.exe', shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=None)
我获得的输入以下:
The process tried to write to a nonexistent pipe.
The process tried to write to a nonexistent pipe.
The process tried to write to a nonexistent pipe.
The process tried to write to a nonexistent pipe.
The process tried to write to a nonexistent pipe.
以后,该过程终止,没有会涌现毛病。我正在运转Windows 七。
推举谜底
测验考试:
import subprocess
subprocess.run(["echo", "Hello, world!"], shell=True)
这应用默许的stdout以及stderr,而没有是创立管讲。
佳了闭于子过程。翻开测验考试写进没有存留的管讲的学程便到这里便停止了,愿望趣模板源码网找到的这篇技巧文章能赞助到年夜野,更多技巧学程不妨在站内搜刮。