Python method to get the native IP address under Windows8

  • 2020-04-02 14:42:17
  • OfStack

This example shows how python can get a native IP address under Windows8. Share with you for your reference. The specific implementation method is as follows:


import socket 
hostname = socket.gethostname() 
IPinfo = socket.gethostbyname_ex(hostname) 
LocalIP = IPinfo[2][2] 
print LocalIP

I hope this article has helped you with your Python programming.


Related articles: