import subprocess
# 就用来执行系统命令
import os cmd = r'dir D:\上海python全栈4期\day23 | findstr "py"'
# res = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
# # 从管道中读取数据 管道就是 两个进程通讯的媒介
# # print(type(res.stdout.read().decode("GBK")))
# print(res.stdout.read().decode("GBK"))
# print(res.stderr.read().decode("GBK")) dir = r'dir D:\上海python全栈4期\day23'
find = 'findstr "py"'
"""
stdout 输出管道
stdin 输入管道
stderr 错误管道
"""
res1 = subprocess.Popen(dir,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE) res2 = subprocess.Popen(find,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE,stdin=res1.stdout)
# 从管道中读取数据 管道就是 两个进程通讯的媒介
# print(type(res.stdout.read().decode("GBK")))
# print(res1.stdout.read().decode("GBK"))
print(res2.stderr.read().decode("GBK"),"") # 简单总结 subprocess 主要用于执行系统指令 (启动子进程) 与os.system的不同在于
# subprocess 可以与这个子进程进行数据交换

最新文章

  1. python 数据类型---列表使用之三
  2. WPF 无边框透明按钮
  3. 使用JDK开发WebService
  4. kafka 搭建与使用
  5. Party Games
  6. 【MySQL】通过select语句把一列数据拼接成一条字符串
  7. Python开发【第七篇】:面向对象 和 python面向对象进阶篇(下)
  8. 限制窗口拉伸范围——WM_GETMINMAXINFO
  9. java.net.URLEncode编码 与 URLDecode解码问题
  10. Log4j配置详解及不同的包(package)下的日志写入到不同的日志文件下
  11. form表单中enctype属性作用
  12. Vue组件之全局组件与局部组件
  13. Python基础理论 - 常用模块
  14. jQuery 筛选器1
  15. 公式编辑器MathType基本使用方法总结----应付本科毕业论文完全没问题啦^_^
  16. Unity5 AssetBundle系列——基本流程
  17. hyperledger-fabirc1.2-ca-server的生产示例
  18. postgres配置只能让某一个ip的主机登陆
  19. Apache-Shiro介绍
  20. 原型和原型对象(__proto__和prototype)转

热门文章

  1. mockjs使用
  2. SPA单页面优缺点
  3. vue echarts 动态数据
  4. Redis客户端断开重连功能要点
  5. 使用JavaScript动态刷新页面局部内容
  6. docker 修改port 端口
  7. Bridge (br0) Network on Linux
  8. python3 九九乘法表打印花式操作(然并卵)
  9. a标签中的onclick和href的使用
  10. oracle计算时间常用函数