获得外网IP地址的脚本

#!/usr/bin/python
#coding=utf-8
import socket
import re


def getip():
names,aliases,ips = socket.gethostbyname_ex(socket.gethostname())
for ip in ips :
if not re.match('^192',ip):
print ip

if __name__ == '__main__':
getip()

你可能感兴趣的:(socket,python,脚本)