类的代码如下: using System; using System.Net; using System.Text.RegularExpressions; namespace Keleyi.Com { public class GetInternetIP { public static string GetIP() { using (var webClient = new WebClient()) { try { var temp = webClient.DownloadString("http
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])