簡體   English   中英

隱藏 output 同時仍捕獲它的子進程

[英]hiding output while still capturing it subprocess

grep = subprocess.run(#command, stdout=subprocess.PIPE, shell=True)
result = grep.stdout
text = result.decode('utf-8')

當我運行這個腳本時,我通常沒有控制台 output,但有時我會得到這個:

“100%|████████████████████████████████████| 112/112 [00:17<00 :00, 6.54it/s]"

或這個:

“錯誤(GDocs):請求給出 500”

我不需要的控制台輸出來自標准錯誤。 當我將標准錯誤設置為標准輸出時,兩者都停止向控制台提供 output。

grep = subprocess.run(#command, stdout=subprocess.PIPE, stderr=stdout, shell=True)
result = grep.stdout
text = result.decode('utf-8')

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM