PyMongo搜索生成“InvalidDocument:无法编码对象:regex.regex('RT',flags=regex.V0”)`
当我运行以下代码时:PyMongo搜索生成“InvalidDocument:无法编码对象:regex.regex('RT',flags=regex.V0”)`,regex,python-2.7,pymongo,Regex,Python 2.7,Pymongo,当我运行以下代码时: import pymongo dbClient = pymongo.MongoClient() db = dbClient["tweets"] import regex as re db["tweets"].find_one( {"text": re.compile('RT')} ) 我得到一个例外: InvalidDocument: Cannot encode object: regex.Regex('RT', flags=regex.V0) 看起来pymongo不
import pymongo
dbClient = pymongo.MongoClient()
db = dbClient["tweets"]
import regex as re
db["tweets"].find_one( {"text": re.compile('RT')} )
我得到一个例外:
InvalidDocument: Cannot encode object: regex.Regex('RT', flags=regex.V0)
看起来pymongo不知道如何处理来自的对象。当我导入本机re模块时,编译的正则表达式会按预期被接受