如何将标准输出转换为字符串(Python) [英] How to get stdout into a string (Python)

查看:29
本文介绍了如何将标准输出转换为字符串(Python)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将我通过子进程执行的进程的标准输出捕获到一个字符串中,然后将其放入我正在创建的 wx 应用程序的 TextCtrl 中.我该怎么做?

I need to capture the stdout of a process I execute via subprocess into a string to then put it inside a TextCtrl of a wx application I'm creating. How do I do that?

我还想知道如何确定进程何时终止

I'd also like to know how to determine when a process terminates

推荐答案

来自 子流程文档:

from subprocess import *
output = Popen(["mycmd", "myarg"], stdout=PIPE).communicate()[0]

这篇关于如何将标准输出转换为字符串(Python)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆