Check IP Address with Python

Do you want to check the IP Address with the help of python? So in this trick, I’ll show you how you can check IP addresses using python.

It is a very simple code of 4 lines.

You just have to install the socket package using the pip command. See the following command to install the package.

The above code will install the socket package then you need to import it into your file and use the function of this package.

See the below code.

In the above code, first we imported the socket package then we get the hostname by using the socket.gethostname() function and then use the socket.gethostbyname(host) this function and hostname to check the client’s IP address and finally print the IP address in python output.

Being Tricky 😉

Leave a Reply

Your email address will not be published. Required fields are marked *