2

[when I don't use pretty method it is showing output correctly but in single line][Can anyone help me? thank you in advance]

pratik jaiswal
  • 1,855
  • 9
  • 27
  • 59
  • 1
    You're running this in python not on the mongodb shell, right? Note that the pymongo cursor class (http://api.mongodb.com/python/current/api/pymongo/cursor.html) is different from the MongoDB shell cursor object (https://docs.mongodb.com/manual/reference/method/js-cursor/). It doesn't have a pretty() method. It wouldn't make much sense for it to have it. – tfogo Aug 19 '17 at 19:40
  • 1
    If you're looking for a way to pretty print JSON from python, this answer will help: https://stackoverflow.com/questions/12943819/how-to-prettyprint-a-json-file – tfogo Aug 19 '17 at 19:41

1 Answers1

1

I assume you are running the script on PyMongo so it won't work,pretty() uses in MongoShell Script