本文实例讲述了python获取本机外网ip的方法。分享给大家供大家参考。具体如下:
python从显示ip地址的网站获取本机外网ip,这段python代码抓取网站上的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程序设计有所帮助。
最后
以上就是俏皮冷风最近收集整理的关于python获取本机外网ip的方法的全部内容,更多相关python获取本机外网ip内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复