Python: Print variable in human readable form like print_r in PHP

print_r prints a PHP variable into human readable form.

The same can be achieved in Python using pprint module.

Here is an example python code:


from pprint import pprint

student = {'Student1': { 'Age':10, 'Roll':1 }, 
           'Student2': { 'Age':12, 'Roll':2 }, 
           'Student3': { 'Age':11, 'Roll':3 }, 
           'Student4': { 'Age':13, 'Roll':4 }, 
           'Student5': { 'Age':10, 'Roll':5 }
           }

pprint(student)

Hope it helps. Thanks.