本文實(shí)例講述了python獲取本機(jī)外網(wǎng)ip的方法。分享給大家供大家參考。具體如下:
python從顯示ip地址的網(wǎng)站獲取本機(jī)外網(wǎng)ip,這段python代碼抓取網(wǎng)站上的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
希望本文所述對(duì)大家的Python程序設(shè)計(jì)有所幫助。
新聞熱點(diǎn)
疑難解答
圖片精選