python stdout stderr 一起输出_python – 使用subprocess.Popen()时,stderr和stdout没有输出
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                python stdout stderr 一起输出_python – 使用subprocess.Popen()时,stderr和stdout没有输出
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.                        
                                我正在使用
Python來自動化SVN提交,我想將SVN命令的輸出寫入日志文件.我有的代碼可以使SVN運行,但問題是在成功提交時,子進程調用不會返回我的日志的任何輸出.
當我手動運行SVN時,通過比較,我得到輸出,顯示命令的進度并顯示正在提交的文件.這就是我想要的日志文件. SVN是否將數據輸出到緩沖區而不是stdout或stderr?如何為我的日志捕獲該數據?
這是我正在使用的代碼:
cmd = "svn commit --non-interactive --no-auth-cache -m 'Automatic commit' ./"
process = subprocess.Popen(cmd,
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True)
result = process.wait()
# Output
out = process.stdout.read()
err = process.stderr.read()
當我運行此代碼并且提交成功時,out和err變量都是空的.
總結
以上是生活随笔為你收集整理的python stdout stderr 一起输出_python – 使用subprocess.Popen()时,stderr和stdout没有输出的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: win10如何修改磁盘盘符
- 下一篇: 可汉学院python_可汗学院离线版本
