import geoip2.database
import sys
# ip = input()
ip = '210.32.149.0'
reader = geoip2.database.Reader('./GeoLite2-City.mmdb')
data = reader.city(ip)
def ip_explain(ip):
data = reader.city(ip)
print(data)
a = '_'.join([data.country.names["zh-CN"],data.subdivisions.most_specific.names["zh-CN"],data.city.names["zh-CN"]])
print(a)
ip_explain(ip)
# print ("IP Address: ", ip)
# print ("Country:", data.country.name)
# print ("Subdivisions: ", data.subdivisions.most_specific.name)
# print ("City: ", data.city.name)
# print ("Latitude: ", data.location.latitude)
# print ("Longitude: ", data.location.longitude)
数据挖掘-geoip2工具
最新推荐文章于 2024-08-09 07:37:25 发布