python-commands模块的适用
来源:互联网 发布:魅族云相册软件 编辑:程序博客网 时间:2024/06/04 13:40
commands模块是python的内置模块,他共有三个函数,使用help(commands)可以查看到
FUNCTIONS getoutput(cmd) Return output (stdout or stderr) of executing cmd in a shell. getstatus(file) Return output of "ls -ld <file>" in a string. getstatusoutput(cmd) Return (status, output) of executing cmd in a shell.
1、 commands.getstatusoutput(cmd)返回一个元组(status,output)
status代表的shell命令的返回状态,如果成功的话是0;output是shell的返回的结果
>>> import commands>>> status, output = commands.getstatusoutput("ls")>>> print status0>>> print outputatom:bookstorecookie.py~
2、返回ls -ld file执行的结果.
commands.getstatus(file)
3、判断Shell命令的输出内容
commands.getoutput(cmd)
>>> print commands.getoutput("ls")atom:bookstorecookie.py~
0 0
- python-commands模块的适用
- python模块commands
- python commands模块
- python commands模块
- python模块commands执行系统命令
- python内置模块(commands、sys)
- commands 模块
- commands模块
- commands模块
- [Python] 利用commands模块执行Linux shell命令
- python 常用代码学习笔记之commands模块
- Python -> subprocess, os.system,commands,popend -> 模块对比
- 【Python模块】os & linecache & hashlib & commands & sys & time & datetime
- python commands模块在python3.x被subprocess取代
- Python3中用什么替换commands模块的getstatusoutput()
- SSH WebShell的适用(python)
- [Python] Commands in Django
- longgin、sys、os、commands模块
- uva 11168 Airport
- MyBatis之传入参数parameterType
- ubuntu 查看定时任务日志
- 外部排序
- GeoServer发布ERDASImg
- python-commands模块的适用
- JS文件取当前网址的方法
- VMware Workstation虚拟机装Win7详细高清图文教程
- sqlserver 命令一览表
- 利用customUI自定义EXCEL菜单项之汉化
- 最长上升子序列
- ORA-01795: 列表中的最大表达式数为 1000 解决办法
- 硬中断、软中断和信号
- intellij idea SSM框架(SpringMVC-Spring-Mybatis)整合