python using_regexp.py

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python using_regexp.py相关的知识,希望对你有一定的参考价值。

from pymongo import MongoClient
import sys


client = MongoClient('localhost', 27017)

db = client.reddit
stories = db.stories

def find():
	print "find using regExp"
	query = {'title': {'$regex': 'Google'}}
	selector = {'title': 1, '_id':0}
	try:
		cursor = stories.find(query, selector)
	except:
		print "Unexpected error", sys.exc_info()[0]
	limit = 0
	for doc in cursor:
		print doc
		limit += 1
		if (limit > 10):
			break

以上是关于python using_regexp.py的主要内容,如果未能解决你的问题,请参考以下文章

001--python全栈--基础知识--python安装

Python代写,Python作业代写,代写Python,代做Python

Python开发

Python,python,python

Python 介绍

Python学习之认识python