Created
May 8, 2018 09:19
-
-
Save YanhaoYang/78deb195c487e9ff49809d5271aaa222 to your computer and use it in GitHub Desktop.
Finding local IP addresses using Python's stdlib
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
s.connect(("8.8.8.8", 80)) | |
print(s.getsockname()[0]) | |
s.close() | |
# https://stackoverflow.com/a/166589 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment