本文實例講述了python獲取本機外網ip的方法。分享給大家供大家參考。具體如下:
python從顯示ip地址的網站獲取本機外網ip,這段python代碼抓取網站上的ip地址信息
import urllibimport reprint "we will try to open this url, in order to get IP Address"url = "http://checkip.dyndns.org"print urlrequest = urllib.urlopen(url).read()theIP = re.findall(r"/d{1,3}/./d{1,3}/./d{1,3}./d{1,3}",request)print "your IP Address is: ", theIP
希望本文所述對大家的Python程序設計有所幫助。
新聞熱點
疑難解答