擅长:python、mysql、java
<p>你可以用这样的东西:
<a href="https://github.com/waszil/subpiper" rel="nofollow noreferrer">https://github.com/waszil/subpiper</a></p>
<p>在回调中,您可以做任何您喜欢的事情,日志,写入文件,打印等。它还支持非阻塞模式。</p>
<pre><code>from subpiper import subpiper
def my_stdout_callback(line: str):
print(f'STDOUT: {line}')
def my_stderr_callback(line: str):
print(f'STDERR: {line}')
my_additional_path_list = [r'c:\important_location']
retcode = subpiper(cmd='echo magic',
stdout_callback=my_stdout_callback,
stderr_callback=my_stderr_callback,
add_path_list=my_additional_path_list)
</code></pre>