Python__subprocess模块

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python__subprocess模块相关的知识,希望对你有一定的参考价值。

#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模块的主要内容,如果未能解决你的问题,请参考以下文章

python基础学习日志day5--subprocess模块

python16_day06类RE模块subprocess模块xml模块shelve模块

python学习道路(day7note)(subprocess模块,面向对象)

远程执行命令_python

python2.7.12 subprocess模块文档翻译

python 之subprocess模块