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])
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])