加入收藏 | 设为首页 | 会员中心 | 我要投稿 北几岛 (https://www.beijidao.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

Python3 MongoDB 数据库模糊查询

发布时间:2021-05-21 04:53:33 所属栏目:大数据 来源: https://blog.csdn.net/yilovex
导读:pymongo 模糊查找是通过正则来实现的,正则有两种可选方案 使用 Python 标准库中的 re 模块 使用 pymongo 中的 $regex 方法 data = self.collection.find({'catch_time': re.compile(start_date)}) data = self.collection.find({'catch_time': {'$regex': c

pymongo 模糊查找是通过正则来实现的,正则有两种可选方案

  1. 使用 Python 标准库中的 re 模块

  2. 使用 pymongo 中的 $regex 方法

     data = self.collection.find({'catch_time': re.compile(start_date)})
     data = self.collection.find({'catch_time': {'$regex': catch_date}})
    

(编辑:北几岛)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读