最佳答案
netifaces模块应该这样做.
原文链接:https://www.f2er.com/linux/440889.htmlimport netifaces
addrs = netifaces.ifaddresses('eth0')
addrs[netifaces.AF_INET6][0]['addr']