1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | from urllib import requestimport jsondef GetIPCity(ip,city): data = f.read() st = json.loads(data.decode(‘utf-8‘)) city[0] = st[‘country‘] city[1] = st[‘province‘] city[2] = st[‘city‘]city = ["","",""]ip = "183.62.57.244"GetIPCity(ip,city)print(city) |
原文:http://www.cnblogs.com/qhy285571052/p/5138561.html