Python pretty print table | Example code

Use PrettyTable from prettytable module to pretty print table in Python. There are several ways to print tables in python, namely: Using tabulate() function to print dict and lists texttable PrettyTable Python pretty print table example First, install a pretty table package then import module it into a project file. Output: Read more PrettyTable: https://pypi.python.org/pypi/PrettyTable Read More…


Python pretty print dict | Example code

Use json.dumps() to Pretty Print a Dictionary in Python. Thie function will convert a Python object into a JSON string. The dumps() function accepts 3 parameters used for pretty-printing: the object for conversion, a boolean value sort_keys, which determines whether the entries should be sorted by key, and indent, which specifies the number of spaces Read More…


Python print JSON pretty | Example code

Use JSON dump() method with indent parameter to print JSON pretty in Python. You should use the optional argument indent. Python pretty print JSON example Simple example code Python’s built-in JSON module can handle that for you: Output: Do comment if you have any doubts and suggestions on this Pytho pretty print topic. RohitDegree in Read More…