文档
https://pypi.org/project/netifaces/
安装
pip install netifaces
使用
import netifaces
netifaces.interfaces() # 获取计算机的接口标识符列表
netifaces.ifaddress(‘指定的接口标识符‘)
netifaces.ifaddress(‘en0‘) # 网卡的信息 返回字典
netifaces.geteways() # 获取网关列表
python实用模块之netifaces获取网络接口地址相关信息
原文:https://www.cnblogs.com/weiweivip666/p/14608778.html