![]() ![]() To determine whether the given IP Address is public or private we will first import ipaddress module, and we will use the is_private method of the ipaddress module, which will test the address is allocated for private.Įxample: from ipaddress import ip_address ![]() A public IP address is assigned by the Internet Service Provider(ISP). ![]() This IP address connects you to the world and it’s unique for all. Public IP address – A public IP address is an address that is used to communicate outside the network.This IP address cannot be accessed from devices outside your home or business network. Private IP address – A private IP address is the address of your device which is connected to the home or business network.Python get an IP address from the URL Determine if the given IP Address is public or private using the ipaddress module in python You can refer to the below screenshot for python get IP Address Now, find the IP address by passing the h_name as an argument to the socket.gethostbyname() and store it in a variable.First, import the socket module and then get the h_name using the socket.gethostname().After writing the above code (python get the IP address), Ones you will print “IP_addres” then the output will appear as “ Host Name is: DESKTOP-AJNOCQ Computer IP Address is: 192.168.45.161 ”. ![]() Print("Computer IP Address is:" + IP_addres) To get the IP address in Python of your computer we need to import the socket library, and then we can find the IP address of the computer, laptop, etc and they have their unique IP address. All devices that are connected to an internet connection have a unique IP Address.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |