python3脚本获取本机公网ip

python脚本获取本机公网ip

 

1.获取公网IP地址方式,访问:http://txt.go.sohu.com/ip/soip

2.代码实现

import requests

import re

req=requests.get("http://txt.go.sohu.com/ip/soip")

ip=re.findall(r'd+.d+.d+.d+',req)

print(ip[0])

原文地址:https://www.cnblogs.com/it-tsz/p/10227163.html