Python subprocess系统命令执行模块

2.subprocess

作用:

执行系统命令

call([commond],shell=True) 执行命令

shell = True 用原生的shell去执行命令而并非python的内部shell环境去执行 漏洞权限问题

shell = True 必须为字符串 shell = False 必须为序列

check_output 返回命令的执行结果

check_all 如果结果为0则返回0 如果命令执行出错则抛出异常

Popen

交互时

subprocess.Popen([python],stdin=subprocess.PEIE,stdout=subprocess.PEIE,stderr=subprocess.PEIE)

posted on 2015-12-18 11:42  Alanpy  阅读(247)  评论(0编辑  收藏  举报

导航