简体   繁体   English

如何打印我的 pymongo.cursor.Cursos 对象的结果?

[英]How to print the result of my pymongo.cursor.Cursos object?

This is my code so far:到目前为止,这是我的代码:

from pymongo import MongoClient
client = MongoClient()
client = MongoClient('localhost', 27017)
db = client.local
collection = db.orderbook_update
orderbook = collection.find({
    "lastUpdated": {"$lt": ts}
}).sort("position",pymongo.DESCENDING).limit(1)
print(orderbook)

When I do that, my print(orderbook) gives me that: <pymongo.cursor.Cursor object at 0x7ff7defef828> How am I able to print my result in order to use it?当我这样做时,我的 print(orderbook) 给我: <pymongo.cursor.Cursor object at 0x7ff7defef828>我如何打印我的结果以便使用它? My json file on my database has three main components: lastUpdated, asks, bids.我数据库中的 json 文件包含三个主要组成部分:lastUpdated、asks、bids。 Thank you!谢谢!

order = list(orderbook)

Note: Once you do do this cursor object will not be available注意:一旦你这样做,这个游标对象将不可用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM