186-Get local IP address
steve-shambles-2109 Oct 23rd, 2019 114 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- Python code snippets vol 38:
- 186-Get local IP address
- import socket
- def ip_check():
- """ uses the sockets module to find the local IP address """
- s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
- s.connect(("220.127.116.11", 80)) # Ping Google DNS server
- ip_address = s.getsockname()
- return ip_address
RAW Paste Data