Extracting Subnet Mask from my computer python

后端 未结 1 1900
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-27 03:18

Dears I was planning to extract my Subnet mask, I had used the below code but the subnetmask is always 255.255.255.255 which is wrong

import socket                      


        
1条回答
  •  后悔当初
    2021-01-27 03:45

    There are alternatives to netifaces on Windows. You can retrieve the interface information using wmic. wmic has a machine readable output option using XML:

    wmic nic get /format:rawxml 
    

    A python example to parse this output is available.

    0 讨论(0)
提交回复
热议问题