摘要: #!/usr/bin/pythonimportsocketimportstructimportfcntldefgetip(ethname):s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)returnsocket.inet_ntoa(fcntl.ioctl(s.fileno(),0X8915,struct.pack('256s',ethname[:15]))[20:24])if__name__=='__main__':printgetip('eth0')
阅读全文