天天看點

python linux系統中擷取網卡IP

   s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

   IP = socket.inet_ntoa(fcntl.ioctl(

           s.fileno(),

           0x8915,  # SIOCGIFADDR

           struct.pack('24s','eth0')

   )[20:24])

本文轉自 swq499809608 51CTO部落格,原文連結:http://blog.51cto.com/swq499809608/1264328