元组比较中的python列表

元组比较中的python列表,python,sql,sqlite,Python,Sql,Sqlite,我有一个列表和一个元组(来自sqlite查询),如果列表中的项目不在db元组中,我需要检查什么。如果未添加到新作业列表中 links = ["example.com", "mysite.com"] newJobs = [] dbgetLink = cursor.execute("SELECT link from jobs") Output of dbgetLink: ('company.com',) ('mysite.com',)

我有一个列表和一个元组(来自sqlite查询),如果列表中的项目不在db元组中,我需要检查什么。如果未添加到新作业列表中

links = ["example.com", "mysite.com"]
newJobs = []

dbgetLink = cursor.execute("SELECT link from jobs")

Output of dbgetLink: 
('company.com',)
('mysite.com',)

this works but it checks if db is in links list.
But I want it the reverse way if the links list items are in db.

for i in links:
    for row in dbgetLink:
        if row[0] not in links:
            print("False, not in list.", row[0])
            newJobs.append(row[0])

您可以尝试以下列表:

newJobs = [x for x in myList if not x in list(myTuple)]

myList
是您的列表,
myTuple
是您的tuple

我将dbgetLink tuple转换为列表,这与您的代码一起工作