标签: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‘))
标签:har proc pyc out stderr str gbk find user
原文地址:http://www.cnblogs.com/wangmengzhu/p/7364444.html