# _*_ 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"))
网友评论