在python中使用geoip maxmind.dat文件
是否有使用maxmind.dat文件的python库? 我一直在将GeoLite2-City.mmdb与python库geoip2一起使用。但是,它无法读取.dat文件 maxminddb.errors.InvalidDatabaseError:打开数据库文件时出错 (geoip_MAXMIND.dat)。这是有效的MaxMind DB文件吗在python中使用geoip maxmind.dat文件,python,geolocation,Python,Geolocation,是否有使用maxmind.dat文件的python库? 我一直在将GeoLite2-City.mmdb与python库geoip2一起使用。但是,它无法读取.dat文件 maxminddb.errors.InvalidDatabaseError:打开数据库文件时出错 (geoip_MAXMIND.dat)。这是有效的MaxMind DB文件吗 geoip2将仅读取较新的MaxMind DB格式(mmdb)。或者将读取传统的dat格式 import geoip2.database reader=g
geoip2
将仅读取较新的MaxMind DB格式(mmdb
)。或者将读取传统的dat
格式
import geoip2.database
reader=geoip2.database.Reader('GeoLite2-City.mmdb')
try:
response = reader.city(ip_address)
if response is not None:
print response.city.name
print response.subdivisions.most_specific.name
print response.country.name
print response.postal.code
else:
print "Not found\n"
except:
print "error"