1. 首页
  2. 数据库
  3. 其它
  4. Python实现获取命令行输出结果的方法

Python实现获取命令行输出结果的方法

上传者: 2020-12-31 11:42:59上传 PDF文件 36.53KB 热度 17次
本文实例讲述了Python实现获取命令行输出结果的方法。分享给大家供大家参考,具体如下: Python获取命令行输出结果,并对结果进行过滤找到自己需要的! 这里以获取本机MAC地址和IP地址为例! # coding: GB2312 import os, re # execute command, and return the output def execCmd(cmd): r = os.popen(cmd) text = r.read() r.close() return text # write "data" to file-filename def wr
下载地址
用户评论