Tech Study

Write a Python to find local IP addresses using Pythons stdlib

Introduction

Write a Python to find local IP addresses using Pythons stdlib. I have used python 3.7 compiler for debugging purpose.

import socket
print([l for l in ([ip for ip in socket.gethostbyname_ex(socket.gethostname())[2] 
if not ip.startswith("127.")][:1], [[(s.connect(('8.8.8.8', 53)), 
s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET, 
socket.SOCK_DGRAM)]][0][1]]) if l][0][0])

Result

Write a Python to find local IP addresses using Pythons stdlib
Write a Python to find local IP addresses using Pythons stdlib

TaggedWrite a Python to find local IP addresses using Pythons stdlib

Java Final keyword

Introduction : java final keyword The final keyword present in Java programming language is generally used for restricting the user. …

Read more

C++ Memory Management: new and delete

C++ Memory Management We know that arrays store contiguous and the same type of memory blocks, so memory is allocated …

Read more