0
from __future__ import print_function
import pysolr

class SolrFunc:
    def __init__(self,urlx,timex=60):
        self.url=urlx
        self.timer = timex

    def filter_add(self,fill):
        self.filterx = []
        self.filterx.append(fill)

    def filter_adds(self,fills):
        self.filtery= []
        x = fills.split(',')
        for i in x:         
            self.filtery.append(i)

    def query(self):
        solr = pysolr.Solr(self.url,self.timex)
        solr.optimize()
        results = solr.search('*:*',fq = self.filtery)
        for result in results:
            print(result['raw_location']

urly = "http://url/solr/"
testr = SolrFunc(urly,10)
testr.filter_adds('gender:male','country_code:in')
tester.query()

在上面的代码中,我得到:

  File "xyz.py", line 26
    urly = "http://url/solr/"
   ^

SyntaxError:无效的语法

类声明或其他内容是否有问题,因为 url 应该是字符串并且在我执行 urllib.urlopen.read() 时工作​​正常

4

1 回答 1

0

您在上一行缺少右括号:

print(result['raw_location']
于 2013-02-22T06:59:47.383 回答