获取网卡名称及其IP地址的方法
2024-10-13 06:30:30
代码
# -*- coding: utf-8 -*-
import psutil
#获取网卡名称和其ip地址,不包括回环
def get_netcard():
netcard_info = []
info = psutil.net_if_addrs()
for k,v in info.items():
for item in v:
if item[0] == 2 and not item[1]=='127.0.0.1':
netcard_info.append((k,item[1]))
return netcard_info
if __name__ == '__main__':
print get_netcard()
最新文章
- JQuery中ajax的相关方法总结
- 窗口activity
- Uva 110 - Meta-Loopless Sorts(!循环,回溯!)
- pandas 修改 DataFrame 列名
- String作为方法参数传递 与 引用传递
- IOS学习感想
- Spring 使用外部部署文件
- 【转】ubuntu打包压缩命令总结
- selenium webdriver python 环境搭建
- w3wp.exe CPU过百问题
- 对scrapy经典框架爬虫原理的理解
- Windows Server 2016-Hyper-V网络虚拟化概述
- 关于config文件中AppSettings和ConnectionStrings的用法跟区别(转)
- PAT B1013
- BZOJ 3687: 简单题 bitset
- scipy的一些函数名
- [note]What I’ve learnt from working on startups
- git commit 多行注释方法说明
- 演示一个简单的Redis队列
- 阿里云服务主机部署Thinkphp系统错误解决方案
热门文章
- pyharm 上运行 npm 配置方法
- 61、springmvc-异步请求-返回DeferredResult
- Vue动态创建注册component的实例代码
- win32窗口程序分析
- 跟随一条insert语句, 进入TiDB的源码世界(上)
- Java链接Redis时出现 “ERR Client sent AUTH, but no password is set”
- 点分 TREE
- docker 部署nestjs应用
- Educational Codeforces Round 49 (Rated for Div. 2)
- windows2008服务器设置系统启动时程序自动运行