2024-05-23 21:12:47 发布
网友
我已经查找了MongoDB的print pretty,我知道如何从shell中完成它。我找不到的是如何使用PyMongo,这样当我在eclipse中运行它时,输出将很漂亮地打印出来,而不是全部打印在一行中。我现在有:
cursor = collection.find({}) for document in cursor: print(document)
这将打印我收藏中的所有内容,但我收藏中的每个文档只打印一行。我怎样才能把它改成漂亮的印刷品?
PyMongo将文档作为Python数据结构获取。所以你可以这样使用pprint:
pprint
from pprint import pprint cursor = collection.find({}) for document in cursor: pprint(document)
PyMongo将文档作为Python数据结构获取。所以你可以这样使用
pprint
:相关问题 更多 >
编程相关推荐