python3+ 模块学习 之 subprocess
subprocess
模块方法:
call()
check_call()
check_output()
以上三个方法用于创建一个子进程,父进程等待子进程结束。若shell = true, 则shell 参数以字符串形式给出,否则,则以序列的形式给出。
Popen 对象:
child = Popen((args, bufsize=-1, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=True,shell=False,
cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0, restore_signals=True,
start_new_session=False, pass_fds=()))
Use communicate() rather than .stdin.write, .stdout.read or .stderr.read to avoid deadlocks due to any of the other OS pipe buffers filling up and blocking the child process.
对象方法:
child.poll() # 检查子进程状态
child.kill() # 终止子进程
child.send_signal() # 向子进程发送信号
child.terminate() # 中止子进程
child.wait() #等待子进程终止
child.communicate() #和子进程交互
python3+ 模块学习 之 subprocess的更多相关文章
- python3+ 模块学习 之 re
re 模块 参考:Python3 如何优雅地使用正则表达式(详解系列) Python3 正则表达式特殊符号及用法(详细列表) (出处: 鱼C论坛) 正则表达式 常用元字符:. ^ $ * + ? ...
- 吴裕雄--天生自然python学习笔记:Python3 模块
Python3 模块 在前面的几个章节中我们脚本上是用 python 解释器来编程,如果你从 Python 解释器退出再进入,那么你定义的所有的方法和变量就都消失了. 为此 Python 提供了一个办 ...
- python 常用模块 time random os模块 sys模块 json & pickle shelve模块 xml模块 configparser hashlib subprocess logging re正则
python 常用模块 time random os模块 sys模块 json & pickle shelve模块 xml模块 configparser hashlib subprocess ...
- python3.4学习笔记(十七) 网络爬虫使用Beautifulsoup4抓取内容
python3.4学习笔记(十七) 网络爬虫使用Beautifulsoup4抓取内容 Beautiful Soup 是用Python写的一个HTML/XML的解析器,它可以很好的处理不规范标记并生成剖 ...
- Day5 - Python基础5 常用模块学习
Python 之路 Day5 - 常用模块学习 本节大纲: 模块介绍 time &datetime模块 random os sys shutil json & picle shel ...
- (转)Python3 模块3之 Urllib之 urllib.parse、urllib.robotparser
原文:https://blog.csdn.net/qq_36148847/article/details/79153738 https://blog.csdn.net/zly412934578/art ...
- python3.4学习笔记(二十四) Python pycharm window安装redis MySQL-python相关方法
python3.4学习笔记(二十四) Python pycharm window安装redis MySQL-python相关方法window安装redis,下载Redis的压缩包https://git ...
- python3.4学习笔记(二十三) Python调用淘宝IP库获取IP归属地返回省市运营商实例代码
python3.4学习笔记(二十三) Python调用淘宝IP库获取IP归属地返回省市运营商实例代码 淘宝IP地址库 http://ip.taobao.com/目前提供的服务包括:1. 根据用户提供的 ...
- python3.4学习笔记(十六) windows下面安装easy_install和pip教程
python3.4学习笔记(十六) windows下面安装easy_install和pip教程 easy_install和pip都是用来下载安装Python一个公共资源库PyPI的相关资源包的 首先安 ...
随机推荐
- April Fools Day Contest 2014
April Fools Day Contest 2014 A.C.H三道题目 ============================================================= ...
- 用composer安装Yii
YII2通过Composer安装方法http://www.yiichina.com/download 一.Composer安装首先到https://getcomposer.org/doc/00-int ...
- 『U3D学习』破坏神回忆图<一>任务系统
学习资料:siki老师<泰斗破坏神> 联系QQ:1790555618 功能描述:任务面板内容生成,角色进行任务,自动寻路到指定地点. 从今天起,本人会发学习回忆图,先总结开发阶段功能,后续 ...
- bash while/until循环学习
while循环:条件满足,则循环:失败,则退出 如何退出? 必须有时刻,条件测试不成功 ? :条件控制变量 while 条件测试:do 循环体 done until循环:条件不满足,则循环:否则,退出 ...
- 兼容ie7、8、9、10、FF、Chrome的遮罩显示
经常碰到这种情形,要实现图片上有一层遮罩和按钮,鼠标滑过时遮罩颜色变深且按钮图片变化,磕磕碰碰终于弄出来题目所述兼容的解决方案. 对于遮罩的实现,将遮罩层.按钮.图片放置在同一个div中,根据abso ...
- 关于是用dotnet获取本机IP地址+计算机名的方法
印象中在maxscript帮助文档里找到过方法,但是当时没记下来.只能通过dotnet实现了. 如果电脑有无线网卡和本地连接,可能会出现乱码,也问了写dotnet的朋友,提供了一些思路,不过最终还是使 ...
- C# 导入Excel到DataSet中
class Import { /// <summary> /// 导入Excel到DataSet中 /// </summary> /// <param name=&quo ...
- redis 3.2.6 on ubuntu 14.04
1. official site: https://github.com/antirez/redis/releases 2. compile and setup tar zxf redis-3.2.6 ...
- oracle case when
http://www.cnblogs.com/kevin2013/archive/2010/07/02/1769682.html
- 黑客攻击常用CMD命令大全
黑客常用命令大全net user heibai lovechina /add 加一个heibai的用户密码为lovechina net localgroup Administrators heibai ...