问题
So I searched a little on the Internet and I found that the socket class can return the IPv4 address from the domain name in python. IP address of domain on shared host says how to do it.
Can I do exactly the same thing but return IPv6 address? It looks like support for IPv6 in Python is a bit limited and I found no resources searching on the Internet.
回答1:
Take a look here, I think this is what you are looking for.
socket.getaddrinfo("example.com", None, socket.AF_INET6)
回答2:
You can use this convert. Ipv4 to ipv6. IPv4 to IPv6
来源:https://stackoverflow.com/questions/17775365/return-ipv6-address-python-from-domain-name