python 执行命令 获取返回值 和 print内容 用module commands
2011-02-17 16:00
316 查看
如果想获取执行命令的状态值,也就是$?, 可以用os.system( cmd )
如果想获取执行命令的print内容, 可以用os.popen( cmd ).read()
如果既想获取状态值,也想获取打印的内容?。。。。
import commands
stat, content = commands.getstatusoutput( cmd )
stat is the exit code
content is the content for printing
如果想获取执行命令的print内容, 可以用os.popen( cmd ).read()
如果既想获取状态值,也想获取打印的内容?。。。。
import commands
stat, content = commands.getstatusoutput( cmd )
stat is the exit code
content is the content for printing
相关文章推荐
- python执行系统命令后获取返回值
- python执行系统命令后获取返回值的几种方式
- python 执行shell命令无法获取返回值的解决方法
- python中subprocess.Popen执行命令并持续获取返回值
- python执行系统命令后获取返回值的几种方式集合
- java 中调用window系统中的文件,或者执行命令(shell、.CMD、.EXE)并获取返回值
- 使用cocos studio打包apk报错或者用python打包出错,执行命令出错,返回值:
- Python输出内容的三种方式:print输出 python脚本执行 linux直接执行
- 在C/python中执行linux命令并得到返回值以及输出
- 使用cocos studio打包apk报错或者用python打包出错,执行命令出错,返回值:
- [Python]paramiko实时获取命令执行输出及sftp上传
- python学习五:执行linux命令的两种方法、提高运行效率、进制转换、切片详解、ip和mac获取
- 使用cocos studio打包apk报错或者用python打包出错,执行命令出错,返回值:
- 使用popen()执行shell命令并获取内容
- python 获取当前执行的命令 处于什么文件内
- C#调用cmd执行命令获取返回值
- Python如何执行存储过程,获取存储过程返回值
- python 调用系统命令 获取返回内容
- bat文件中使用DOS命令如何截取字符串&如何执行“字符串命令”&获取文件文件内容并赋值给变量
- 使用cocos studio打包apk报错或者用python打包出错,执行命令出错,返回值: