python subprocess
来源:互联网 发布:手机视频制作软件 编辑:程序博客网 时间:2024/06/07 01:02
首先python进程中,如果需要调用其他的程序,比如bash等,有以下两种情况
1.主程序需要等待被调用程序执行结束,并且需要返回信息等,使用以下方法
import subprocesscmd = "xterm -hold -e scipt.sh"# no block, it start a sub process.p = subprocess.Popen(cmd , shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)# and you can block util the cmd execute finishp.wait()# or stdout, stderr = p.communicate()
注意communicate返回的是tuple,包含了stdout和stderr
2.启动其他进程即可,不需要等待,而是继续运行
去掉上面代码的wait即可
subprocess.call = subprocess.Popen().wait()
0 0
- python subprocess
- python subprocess
- PYTHON SUBPROCESS
- Python --- subprocess
- python subprocess
- python subprocess
- python -- subprocess
- python subprocess
- Python-subprocess
- python----subprocess
- Python 中的 Subprocess
- Python中的subprocess
- Python模块subprocess小记
- Python模块subprocess小记
- python subprocess Popen
- python得subprocess模块
- Python中subprocess学习
- Python模块subprocess小记
- 3. Dubbo原理解析-Dubbo内核实现之动态编译
- R: 矩阵运算及常用函数 III - *apply Part I
- 一句话获取机器ip
- POJ 1654 Area 有向面积
- Candy
- python subprocess
- Android四大组件详解
- linux 下查看一个进程运行路径的方法
- J.U.C原子工具类AtomicXXX中,set和lazySet的区别
- 人见人爱A^B
- ARM PL330 DMA控制器开发(二)
- Redis关键点(rehash)<转>
- Qt 中界面间的执行调用QDialog::Accepted
- mac开发给字符串加入下划线的方法。