如何获取包含管道的Python子进程命令的输出?

如何获取包含管道的Python子进程命令的输出?,第1张

如何获取包含管道的Python子进程命令的输出

试试这个:

import subprocess# cmd contains shell commandcmd="your command shell"process = subprocess.Popen(cmd,shell=True,stdin=None,stdout=subprocess.PIPE,stderr=subprocess.PIPE)# The output from your shell commandresult=process.stdout.readlines()if len(result) >= 1:    for line in result:        print(line.depre("utf-8"))


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5632468.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-15
下一篇2022-12-16

发表评论

登录后才能评论

评论列表(0条)

    保存