pymongo 中输出的漂亮打印 [英] Pretty printing of output in pymongo
问题描述
我正在使用 pymongo 驱动程序通过 Python 与 Mongodb 一起工作.每次我在 python shell 中运行查询时,它都会返回一些非常难以理解的输出.我在 mongo shell 中使用了 .pretty()
选项,它以结构化的方式提供输出.
I am using pymongo driver to work with Mongodb using Python. Every time when I run a query in python shell, it returns me some output which is very difficult to understand. I have used the .pretty()
option with mongo shell, which gives the output in a structured way.
我想知道pymongo中是否有类似pretty()
的方法,可以结构化的返回输出?
I want to know whether there is any method like pretty()
in pymongo, which can return output in a structured way ?
推荐答案
我想知道PyMongo中有没有
pretty()
之类的方法
否 PyMongo 不提供这种方法.它仅在 shell 中可用.您需要使用 pprint
pprint
模块中的函数.
No PyMongo doesn't provide such method. It is only available in the shell.
You need to use the pprint
function from the pprint
module.
这篇关于pymongo 中输出的漂亮打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!