Pretty printing of output in pymongo

前端 未结 4 1720
太阳男子
太阳男子 2021-01-12 17:25

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 difficul

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-12 18:00

    Actually you can also program it by yourself like:

    db = connection.[dbname]
    
    collection = db.[yourcollectionname]
    
    for col in collection.find({}):
    
        for keys in col.keys(): 
    
            print ('{', keys, ":" , col[keys] , '}' )
    

    I think this will be helpful or take it as an option.

提交回复
热议问题