美文网首页
get_country_code.md

get_country_code.md

作者: 洛神鬼道 | 来源:发表于2017-12-27 14:41 被阅读0次
​# _*_ conding:utf-8 _*_
import json
from urllib.request import urlopen


def GetCountry(ipaddr):
    response = urlopen("http://freegeoip.net/json/" + ipaddr).read()
    rjson = json.loads(response)
    return rjson.get("country_code")


print(GetCountry("50.78.253.58"))

网友评论

      本文标题:get_country_code.md

      本文链接:https://www.haomeiwen.com/subject/edjugxtx.html