码迷,mamicode.com
首页 > 编程语言 > 详细

Python__subprocess模块

时间:2017-08-15 13:24:35      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:har   proc   pyc   out   stderr   str   gbk   find   user   

#Author wangmengzhu
import subprocess
subprocess.Popen(r‘dir C:\Users\wangmengzhu\PycharmProjects\MZ\day7\configparser模块.py‘,shell = True)

#管道符号
res = subprocess.Popen(r‘dir C:\Users\wangmengzhu\PycharmProjects\MZ\day7\configparser模块.py‘,shell = True,stdout = subprocess.PIPE)
print(res.stdout.read().decode(‘gbk‘))

res = subprocess.Popen(r‘dir C:\Users\wangmengzhu\PycharmProjects\MZ\day7\configparser模块.py‘,shell = True,stdout = subprocess.PIPE,
stderr = subprocess.PIPE)
print(‘=====>‘,res.stderr.read().decode(‘gbk‘))


#dir file_path|findstr xml$
res1 = subprocess.Popen(r‘dir filepath‘,shell = True,stdout = subprocess.PIPE)
res2 = subprocess.Popen(r‘findstr xml$‘,shell = True,stdin = res1.stdout,stdout = subprocess.PIPE)
print(res2.stdout.read().decode(‘gbk‘))

Python__subprocess模块

标签:har   proc   pyc   out   stderr   str   gbk   find   user   

原文地址:http://www.cnblogs.com/wangmengzhu/p/7364444.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!