getmyip 218 B

1234567891011
  1. from socket import socket, SOCK_DGRAM, AF_INET
  2. def localip():
  3. s = socket(AF_INET, SOCK_DGRAM)
  4. s.connect(('114.114.114.114', 0))
  5. return s.getsockname()[0]
  6. if __name__ == "__main__":
  7. print localip()