python获取到本机的公网IP

5行代码获取到本机的公网IP

from urllib.request import urlopen
import re
text = str(urlopen("http://txt.go.sohu.com/ip/soip").read())
ip = re.findall(r'd+.d+.d+.d+',text)
print(ip[0])
原文地址:https://www.cnblogs.com/pythonliuwei/p/14487208.html