|  |      1dreampuf      2013-03-31 19:56:19 +08:00 print json.dump(list(result)) | 
|      2013231      2013-03-31 20:11:55 +08:00 json.dumps([dict((key, item[key]) for key in item if key != '_id') for item in doc.find()]) | 
|      3013231      2013-03-31 20:13:44 +08:00 上面的答案要修改一下. json.dumps([dict((key, item[key]) for key in item if key != '_id') for item in result]) | 
|      4ritksm      2013-03-31 20:26:23 +08:00  1 亲们。。。要去掉_id直接在find里加参数不就得了。。。find({}, {"_id":0}) | 
|      5ritksm      2013-03-31 20:26:59 +08:00 建议lz参考document。。。。http://api.mongodb.org/python/2.5/ | 
|      6hilenlai OP @dreampuf 这个结果不对撒~ @013231 这个可行!!得到一串 [{"age": 25.0, "name": "zhangsan", "sex": 1.0}, {"age": 25.0, "name": "zhangsan", "sex": 1.0}, {"age": 25.0, "name": "zhangsan", "sex": 1.0}, {"age": 25.0, "name": "zhangsan", "sex": 1.0}, {"age": 25.0, "name": "zhangsan", "sex": 1.0}, {"age": 25.0, "name": "zhangsan", "sex": 1.0}, {"age": 25.0, "name": "zhangsan", "sex": 1.0}, {"age": 25.0, "name": "zhangsan", "sex": 1.0}] @ritksm 其实不是去掉id.. mongo查出来的不是bson嘛。 然后我想转化成json :) | 
|  |      7binux      2013-03-31 20:40:50 +08:00 | 
|      9ritksm      2013-03-31 20:53:17 +08:00 @hilenlai bson是mongodb用来存储的格式。。。。pymongo查出来已经是dict了。。。。想知道是什么类型请用type(X) http://d.pr/i/2cSz BTW:Connection已经在新版本的pymongo中被弃用了。。。用MongoClient吧。。。 | 
|  |      11ooscrewyou      2013-04-09 22:12:35 +08:00 @hilenlai 和Python版本沒關係 Connection已經deprecated了 |