Python3-subprocess模块-子进程管理
2024-09-06 17:14:00
简单介绍
subprocess模块可以创建新的进程,执行shell命令、Python脚本等
代码示例
import subprocess # 1.执行进程,并获取返回码
return_code = subprocess.call(["ls", "-l"])
print(return_code) # 2.执行进程,并获取进程输出内容
return_cont = subprocess.check_output(["ipconfig"])
print(return_cont.decode("gbk")) # 3.传递原生shell命令字符串执行,不推荐
subprocess.call("ls -l", shell=True)
subprocess.check_output("ls -l", shell=True)
1.执行shell命令
参考资料
http://python.usyiyi.cn/translate/python_352/library/subprocess.html
最新文章
- web前端基础知识 Dom
- svn更新操作时提示database is locked
- 洛谷U5653 宋荣子的小饼干
- ajax中文传送到模板显示为null
- mysql:批量更新
- 【工具推荐】ELMAH——可插拔错误日志工具
- JS - To my gril
- 进程kswapd0与events/0消耗大量CPU的问题
- handler.post 为什么要将thread对象post到handler中执行呢?
- LINQ to SQL语句之Join和Order By
- memcached在windows下的安装与命令使用方法
- shuffle() 函数(转)
- AIX-du
- uva 10929 - You can say 11
- 实现TCP断点上传,后台C#服务实现接收
- spark install
- 云计算之路-阿里云上:节点 CPU 波动引发 docker swarm 集群故障
- python的日志配置
- Spring.Net 简单实例-01(IOC)
- Percona XtraDB Cluster vs Galera Cluster vs MySQL Group Replication