我想将列表传递给正则表达式,如下所示。我无法找到证据来了解如何联合$in
和$regex
query = {"platform": {"$regex": {"$in": [platform_list]}, "$options":"i"}, "$or": []}
result = mongo.db.xxx.find(query)
我收到错误:
pymongo.errors.OperationFailure: database error: Can't canonicalize query: BadValue $regex has to be a string
如何格式化字符串,以便我可以将查询应用于platform_list