python获取windows所有的网卡名

在Windows环境下,使用python获取系统所有的网卡名称 原理,python调用系统cmd执行ipconfig命令获取网卡信息,然后使用正则表达式获取想要的内容 d

在Windows环境下,使用python获取系统所有的网卡名称

原理,python调用系统cmd执行ipconfig命令获取网卡信息,然后使用正则表达式获取想要的内容

def get_iface():
        result = os.popen('ipconfig')
        res = result.read()
        resultlist = re.findall('''(?<=以太网适配器 ).*?(?=:)|(?<=无线局域网适配器 ).*?(?=:)''', res)
        num = 0
        while True:
            if num >= len(resultlist):
                return resultlist
            elif '本地连接' in resultlist[num]:
                resultlist.remove(resultlist[num])
            else:
                num = num + 1

发布者:admin,转转请注明出处:http://www.yc00.com/web/1741227501a4329801.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信