python - Python subprocess.Popen() 和 stdout 文件对象关联
问题描述
我想知道subprocess.Popen()对象和stdout之间的关联以及它如何将Popen实例转换为文件对象。
type(subprocess.Popen) # <type 'type'>
subprocess.Popen(":", shell=True).__class__ # <class 'subprocess.Popen'>
type(subprocess.Popen(":", shell=True, stdout=subprocess.PIPE).stdout) # <type 'file'>
但,
dir(subprocess.Popen)
没有标准输出作为其成员
解决方案
stdout
是类Popen
中的一个属性,定义如下
self.stdout = None
推荐阅读
- r - 重塑我的数据以引入辅助轴(ggplot2)
- atom-editor - 如何从 Windows 中的目录运行 atom
- node.js - 如何在 Nestjs 中使用请求正文上传文件和其他字段
- reactjs - 执行上下文不会像通常那样从 getStaticPaths 移动到 getStaticProps
- sql-server - 用 WITH 选择
- javascript - 如何切换布尔特定状态?
- amazon-web-services - Quicksight Embedded:使用我的 react + django App 评估技术可行性
- reactjs - 反应原生文本不更新
- c# - 应用客户端投影后无法翻译集合操作
- bash - 对参数定义的 JSON 进行 PUT 调用