以下查询在 mongodb 中运行良好:
db.article.find({$and:[{"version":1},{"targetGroup" : ["ecpa"]},{"state":"published"}]}).limit(5).pretty ()
但是当我从 python 运行它时,它会抛出错误作为无效语法:
from pymongo import MongoClient
import pprint
client = MongoClient('127.0.0.1', 27300)
db = client['data']
article= db.article
articles = article.find({$and:[{"version":1},{"targetGroup" : ["ecpa"]},{"state":"published"}]})
for item in articles:
pprint.pprint(item)
我需要改变什么才能完成这项工作?