commands模块
来源:互联网 发布:smart forfour 知乎 编辑:程序博客网 时间:2024/05/29 16:18
commands只能在linux下使用
#!/usr/bin/env python#-*-coding:utf-8 -*-import commandscmd = 'ls /home/'result = commands.getoutput(cmd)print(type(result))print (result)#commands.getoutput的返回值只有返回结果,没法进行判断结果是否正常cmd = 'ps -test'status, result = commands.getstatusoutput(cmd)print(type(result))print(result)print(type(status))print(status)#commands.getstatusoutput的返回值是一个tuple类型#第一个值接受的状态码,返回结果是一个int类型,如果返回值是0,说明执行正常,如果非0,说明结果异常#第二个值接受返回的结果,返回结果是一个str类型
wq保存退出。
阅读全文
0 0
- commands 模块
- commands模块
- commands模块
- python模块commands
- python commands模块
- python commands模块
- python-commands模块的适用
- longgin、sys、os、commands模块
- 利用commands模块执行Linux shell命令
- 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
- 725. Split Linked List in Parts
- 【解题报告】aoj夺宝奇兵——并查集&&某魔法的数据链
- 关于Centos NTP服务器的设置
- OS 模块
- regex(compilation flag, sub(), non-greedy match)
- commands模块
- SpringBoot四大神器之Actuator
- JAVA学习笔记_内存溢出代码实现
- fingerprint image segmentation
- sys模块
- 35. Search Insert Position
- Angular 4入门教程系列:15:NG-ZORRO的使用方式
- 错题整理
- HDU1012 POJ1517 ZOJ1113 UVALive2083 u Calculate e【水题】