import socket
import urllib2
def public_ip():
read = urllib2.urlopen('http://ipecho.net/plain').read()
return read.decode('utf-8')
def local_ip():
return socket.gethostbyname(socket.gethostname())
if __name__ == "__main__":
print("Getting public and local IP...")
print("Public IP: {}\nLocal IP: {}".format(public_ip(), local_ip()))
获取ip地址
最新推荐文章于 2025-12-01 13:49:36 发布
8694

被折叠的 条评论
为什么被折叠?



