python獲取本機外網(wǎng)ip的方法
更新時間:2015年04月15日 12:31:33 作者:令狐不聰
這篇文章主要介紹了python獲取本機外網(wǎng)ip的方法,可實現(xiàn)從外網(wǎng)顯示IP的網(wǎng)站獲取本機IP的功能,非常具有實用價值,需要的朋友可以參考下
本文實例講述了python獲取本機外網(wǎng)ip的方法。分享給大家供大家參考。具體如下:
python從顯示ip地址的網(wǎng)站獲取本機外網(wǎng)ip,這段python代碼抓取網(wǎng)站上的ip地址信息
import urllib import re print "we will try to open this url, in order to get IP Address" url = "http://checkip.dyndns.org" print url request = 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程序設計有所幫助。
相關文章
python3.6利用pyinstall打包py為exe的操作實例
今天小編就為大家分享一篇python3.6利用pyinstall打包py為exe的操作實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-10-10python飛機大戰(zhàn) pygame游戲創(chuàng)建快速入門詳解
這篇文章主要介紹了python飛機大戰(zhàn) pygame游戲創(chuàng)建,結合實例形式詳細分析了Python使用pygame創(chuàng)建飛機大戰(zhàn)游戲的具體步驟與相關操作注意事項,需要的朋友可以參考下2019-12-12