尝试重构collectionsQuery中的keywordAlt位def countSubject(genres): for keyword in genres: keywordAlt = '%'+keyword+'%' collectionsQuery = Collection.select().join(Subject).where(Subject.name ** keywordAlt, Subject.name != 'librivox', Subject.name != 'spoken', Subject.name != 'audiobook', Collection.downloads > 50) if collectionsQuery.count() > 5: print keyword, collectionsQuery.count()我正在重构此代码段,并且想要首先删除keywordAlt位,并将文本包含在我的查询中。然而 collectionsQuery = Collection.select().join(Subject).where(Subject.name ** '%'+keyword+'%', Subject.name != 'librivox', Subject.name != 'spoken', Subject.name != 'audiobook', Collection.downloads > 50)但是,使用第二种方法,它可以匹配所有内容。 collectionsQuery = Collection.select().join(Subject).where(Subject.name ** %keyword%, Subject.name != 'librivox', Subject.name != 'spoken', Subject.name != 'audiobook', Collection.downloads > 50)这被解释为对“关键字”的通配符搜索正确的语法是什么?
添加回答
举报
0/150
提交
取消