![]() |
VOOZH | about |
Given an IP address in dotted-decimal format (IPv4), the task is to convert it into its corresponding integer value and also convert an integer back into an IP address. For Example:
Input: IP Address -> 192.168.1.1
Output: Integer -> 3232235777Reverse Input: 3232235777
Reverse Output: IP Address -> 192.168.1.1
ipaddress.ip_address() creates and validates an IP address object from a string or an integer. Below is the syntax:
ipaddress.ip_address(address)
In this example, an IP address is converted into its numeric (integer) form using the ipaddress module.
3221225000 123 42540766400282592856903984001653826561
In this example, integer values are converted back into readable IPv4 and IPv6 addresses.
191.255.254.40 0.0.0.123 2001:db7:dc75:365:220a:7c84:d796:6401
The following points explain why IP addresses are often converted into integer form: