0% found this document useful (0 votes)
43 views

Python Script To Convert IPv4 Address Into IPv6

Python platform for machine learning notes 2021

Uploaded by

Athira
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

Python Script To Convert IPv4 Address Into IPv6

Python platform for machine learning notes 2021

Uploaded by

Athira
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

IPv4 to IPv6 Convertor

import ipaddress

def convertusingipaddress(ipv4address):
print(ipaddress.IPv6Address('2002::' + ipv4address).compressed)

ipaddr=input("Enter your ip here: ")


convertusingipaddress(ipaddr)

OUTPUT

=======================================================================================================================================================

Note: In the above-given Python program there is one inbuild library imported to convert the
Ipv4 into Ipv6 i.e.; “ipaddress” After that in the second line one function has been defined
named “convertusingipaddress” inside that function. I have printed using the module
define at the top with the help of “.” Basically, it means the object of that
inbuild module i.e.; “IPv6Address('2002::' + ipv4address)” will be converted in
IPv6, and with “.compressed” I have compressed the original Ipv6 onto the
compressed form of the IP address.

You might also like