使用python获取windows的所有可用mac id

2024-06-11 19:59:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个可以工作的python代码来获取windows机器的所有可用mac id。在我的代码中,我使用子进程来获取所有id并将其附加到一个列表中。我想要一些替代的代码,这是不使用子进程。你知道吗

代码:

   def mac_list():
        """
        List all Mac id's and store as list
        """
        output = subprocess.check_output("getmac").decode('utf-8')
        regex = r"([0-9A-F]{2}[:-]){5}([0-9A-F]{2})"
        matches = re.finditer(regex, output)
        listoutputmac = []
        for matchnum, match in enumerate(matches):
            matchnum = matchnum + 1
            listoutputmac.append("{match}".format(matchnum=matchnum, start=match.start(),
                                                  end=match.end(), match=match.group()))
        return listoutputmac 
  • 我想要这个代码的确切替代品有人知道吗?你知道吗

Tags: 代码机器idoutput进程windowsmacmatch