get_country_code.md

2017-12-27  本文已影响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"))
上一篇 下一篇

猜你喜欢

热点阅读