python获取本机IP方法

python获取本机IP方法,记录下

import fcntlimport structimport socketdef get_local_ip(ifname):    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)     return socket.inet_ntoa(fcntl.ioctl(s.fileno(), 0x8915, struct.pack('256s', ifname[:15]))[20:24]) local_ip = get_local_ip('eth0')print local_ip

原创文章,作者:Tina,如若转载,请注明出处:https://python.01314.cn/201603464.html