我正在使用python3和geolite2,但我发现无法传入要查找的IP地址,并收到以下错误。我已经尝试转换为utf-8和编码,但得到相同的错误。
from geoip import geolite2
ip_address = request.access_route[0] or request.remote_addr
print(">>>", ip_address)
ip_bytes = ip_address.encode('utf-8')
loc = geolite2.lookup(ip_bytes)或
loc = geolite2.lookup(ip_address.encode())以下错误:
TypeError: 'str' does not support the buffer interfaceIP应该采用什么格式。在原始文档中,它是string。
http://pythonhosted.org/python-geoip/
发布于 2015-12-04 22:47:19
我建议尝试官方的Python geoip2 API或python-geoip-yplan。后者是python-geoip的一个分支,具有更好的Python3支持。
https://stackoverflow.com/questions/34068206
复制相似问题