相关疑难解决方法(0)

使用Python获取计算机的外部IP地址

寻找一种更好的方法来获取机器当前的外部IP#...下面工作,但宁愿不依赖外部网站来收集信息......我只能使用与Mac OS捆绑在一起的标准Python 2.5.1库X 10.5.x

import os
import urllib2

def check_in():

    fqn = os.uname()[1]
    ext_ip = urllib2.urlopen('http://whatismyip.org').read()
    print ("Asset: %s " % fqn, "Checking in from IP#: %s " % ext_ip)
Run Code Online (Sandbox Code Playgroud)

python standard-library

58
推荐指数
13
解决办法
8万
查看次数

标签 统计

python ×1

standard-library ×1