我可以使用URL作为geoip2中reader函数的数据库目录吗?

2024-06-17 07:51:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我在跑步

import geoip2.database
reader = geoip2.database.Reader("https://url.com/.../GeoLite2-City.mmdb")

它又回来了

^{pr2}$

有什么方法可以让我引用一个URL作为这个函数的目的地吗?在

编辑:

import geoip2.database
import urllib2
r = urllib2.urlopen("https://url.com/.../GeoLite2-City.mmdb")
temp = r.read()
reader = geoip2.database.Reader(temp)

退货

TypeError: file() argument 1 must be encoded string without NULL bytes, not str

Tags: httpsimportcomurlcityurllib2temp跑步