2013-08-20 78 views
0

我有一个项目,我已经实现了搜索引擎。我们的指南建议我们实施O'Reilly集体智慧2007年书中给出的代码。这是网页编入索引的代码的一部分。我们正在使用Sqlite3数据库。我在代码的最后部分遇到错误,甚至在经过很多研究之后,我没有成功。“sqlite3.operationalerror无法识别的令牌”错误

def addtoindex(self,url,soup): 
if self.isindexed(url): return 
print 'Indexing '+url 
# Get the individual words 
text=self.gettextonly(soup) 
words=self.separatewords(text) 
# Get the URL id 
urlid=self.getentryid('urllist','url',url) 
# Link each word to this url 
for i in range(len(words)): 
    word=words[i] 
    if word in ignorewords: continue 
    wordid=self.getentryid('wordlist','word',word) 
    self.con.execute("insert into wordlocation(urlid,wordid,location)\values (%d,%d,%d)" % (urlid,wordid,i)) 

我收到以下错误在最后一行:

sqlite3.OperationalError:无法识别的标记: “[一些符号,我不知道]”

请帮帮忙!

+0

可能重复的[sqlite3.OperationalError:无法识别的令牌:“01T00”Python日期戳](http://stackoverflow.com/questions/11160637/sqlite3-operationalerror-unrecognized-token-01t00-python-datestamp) – 2013-08-20 12:13:36

+0

我试过但它不工作... –

回答

1

从SQL命令中删除反斜杠。

在Python中,\v指定了一个控制字符(垂直标签)。

+0

可能只是一个空间之前缺少值()? – 2013-08-20 13:24:20

相关问题