In [76]: a Out[76]: '\xe6\xb1\xbd\xe8\xbd\xa6' In [77]: print a 汽车 In [78]: list(db.project.find({'name':{'$regex':a}})) Out[78]: [{u'_id': 139, u'black_list': [], u'created_on': datetime.datetime(2014, 10, 8, 15, 9, 41, 560000), u'effective_time': [1412697600, 1412697600], u'industry_id': 1000, u'name': u'\u7231\u5361\u6c7d\u8f66', u'regex': 0, u'status': 0, u'topic_ids': [2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2029, 2030, 2031, 2032], u'user_id': 44, u'white_list': []}] In [79]: list(db.project.find({'name':re.compile(a)})) Out[79]: [{u'_id': 139, u'black_list': [], u'created_on': datetime.datetime(2014, 10, 8, 15, 9, 41, 560000), u'effective_time': [1412697600, 1412697600], u'industry_id': 1000, u'name': u'\u7231\u5361\u6c7d\u8f66', u'regex': 0, u'status': 0, u'topic_ids': [2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2029, 2030, 2031, 2032], u'user_id': 44, u'white_list': []}] In [80]:
原文地址:小计-python调用pymongo模糊正则查询的方法, 感谢原作者分享。
声明:本网页内容旨在传播知识,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。TEL:177 7030 7066 E-MAIL:11247931@qq.com