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:语法无效
在类声明或其他方面是否存在问题,因为当我执行urllib.urlopen.read()时,url应该是字符串并且工作正常
答案 0 :(得分:0)
您错过了上一行的右括号:
print(result['raw_location']