code-dumps/py/print-env-ip.py

7 lines
149 B
Python
Raw Normal View History

2024-02-22 15:37:33 +08:00
#!/usr/bin/python3
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80))
print(s.getsockname()[0])
s.close()