从域名返回IPv6地址Python

问题描述:

所以我在互联网上搜了一下,发现socket类可以从python中的域名返回IPv4地址。 共享主机上的域名IP地址说如何处理。

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.

我可以做同样的事情,但是返回IPv6地址?看来,在Python中支持IPv6是有限的,我发现没有资源在互联网上搜索。

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.

看看这里,我想这是你正在寻找的。​​ p>

Take a look here, I think this is what you are looking for.

socket.getaddrinfo("example.com", None, socket.AF_INET6)