作者:朱金灿 来源:http://blog.csdn.net/clever101 获取本地IP地址有两种做法.一种是使用gethostname函数,代码如下: bool CSocketComm::GetLocalAddress(std::string& strAddress) { char strHost[HOSTNAME_SIZE] = { 0 }; // get host name, if fail, SetLastError is called if (SOCKET_ERROR != ge
代码 # -*- 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])) retu