获取语法错误,其中没有b

2024-04-24 23:03:45 发布

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

我有以下代码片段:

import sqlite3
import cld
import langid

languagedata = [] #list for the returned data from database
n = -1
connector = sqlite3.connect("GERMANY.db")
selecter = connector.cursor()
selecter.execute(''' SELECT title FROM DATAGERMANY''')
for row in selecter: #iterate through all the rows in db
    print (row)
    lan = langid.classify("{}".format(row)) #identify the language
    print (lan)
    connector.execute('''update DATAGERMANY set title_abbreviation_langid=? , title_reliability_langid=? where id_db == ? ''',(lan[-2], lan[-1])
 connector.commit() #save changes
 connector.close()

我试了100次,效果很好。我添加了另一个for loop,然后又删除了它。所以我不应该修改密码。但是现在我得到了一个Invalid Syntax错误。你知道吗

怎么可能?!你知道吗

traceback 你知道吗

注意:没有关于错误的更多信息。你知道吗


Tags: theinimportforexecutedbconnectortitle
1条回答
网友
1楼 · 发布于 2024-04-24 23:03:45

此行缺少结束符:

connector.execute('''update DATAGERMANY set title_abbreviation_langid=? , title_reliability_langid=? where id_db == ? ''',(lan[-2], lan[-1])) # added paren here

我添加了一个结束参数,您的代码现在应该可以了。你知道吗

相关问题 更多 >