get_country_code.md

​# _*_ 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)