pip install pymongo
import pymongo
$or 查询
find({"$or":[{"name":"test"},{"age":{"$gt":25}}]})
You can do with regex which does not contain word. Also you can use $options => i for case insensitive search
Doesn't Contains string
db.collection.find({name:{'$regex' : '^((?!string).)*$', '$options' : 'i'}})
Exact case insensitive string
db.collection.find({name:{'$regex' : '^string$', '$options' : 'i'}})
Start with string
db.collection.find({name:{'$regex' : '^string', '$options' : 'i'}})
End with string
db.collection.find({name:{'$regex' : 'string$', '$options' : 'i'}})
Contains string
db.collection.find({name:{'$regex' : 'string', '$options' : 'i'}})
Using re
You need to compile the regex with the re module:
import re rgx = re.compile('.*IP.*', re.IGNORECASE) # compile the regex cursor = db.tweets.find({'text':rgx},{'text':1,'created_at':1})
You can use re.IGNORECASE
as flag if you want to match iP, Ip and ip as well. If you do not want that, you can drop the re.IGNORECASE
part.
stat -c "%a %n" file , 755, 644
ModuleNotFoundError: No module named 'MySQLdb', ...
Ubuntu18.04下使用pyenv安装python报错:BUILD FAILED (Ubun ...
dell提供了工具远程查看服务器硬件状态,可以修改硬件的参数,可以远程连接过去直接修改,就不需要 ...
启动报undefined symbol: EVP_CIPHER_CTX_cleanup错误。op ...
ubuntu开启crontab日志记录及解决No MTA installed, discardi ...
暂时还没有评论,第一个来评论吧!