隐藏输出同时仍然捕获它子进程
hiding output while still capturing it subprocess
grep = subprocess.run(#command, stdout=subprocess.PIPE, shell=True)
result = grep.stdout
text = result.decode('utf-8')
当我 运行 这个脚本时,我通常没有控制台输出,但有时我会得到这个:
"100%|████████████████████████████████████| 112/112 [ 00:17<00:00, 6.54it/s]"
或者这个:
“错误(GDocs):请求给出 500”
我不需要的控制台输出来自 stderr。当我将 stderr 设置为等于 stdout 时,两者都停止向控制台提供输出。
grep = subprocess.run(#command, stdout=subprocess.PIPE, stderr=stdout, shell=True)
result = grep.stdout
text = result.decode('utf-8')
grep = subprocess.run(#command, stdout=subprocess.PIPE, shell=True)
result = grep.stdout
text = result.decode('utf-8')
当我 运行 这个脚本时,我通常没有控制台输出,但有时我会得到这个:
"100%|████████████████████████████████████| 112/112 [ 00:17<00:00, 6.54it/s]"
或者这个:
“错误(GDocs):请求给出 500”
我不需要的控制台输出来自 stderr。当我将 stderr 设置为等于 stdout 时,两者都停止向控制台提供输出。
grep = subprocess.run(#command, stdout=subprocess.PIPE, stderr=stdout, shell=True)
result = grep.stdout
text = result.decode('utf-8')