Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to sort a dictionary using pprint module in python

import pprint

a = {'c': 2, 'b': 3, 'y': 5, 'x': 10}

pp = pprint.PrettyPrinter(sort_dicts=True)
pp.pprint(a)

# Output:
# {'b': 3, 'c': 2, 'x': 10, 'y': 5}
Comment

how to sort a dictionary using pprint module in python

import pprint

a = {'c': 2, 'b': 3, 'y': 5, 'x': 10}

pp = pprint.PrettyPrinter(sort_dicts=True)
pp.pprint(a)

# Output:
# {'b': 3, 'c': 2, 'x': 10, 'y': 5}
Comment

PREVIOUS NEXT
Code Example
Python :: insert data in table python 
Python :: python break for loop 
Python :: numpy vector multiplication 
Python :: python - remove floating in a dataframe 
Python :: python how to draw a square 
Python :: how to simplify fraction in python 
Python :: size of the query process in python BigQuery 
Python :: version python 
Python :: python read integer from stdin 
Python :: how to convert array to vector in python 
Python :: add x=y line to scatter plot python 
Python :: pandas dataframe froms string 
Python :: how to send file using socket in python 
Python :: vscode pylint missing module docstring 
Python :: append dataframe pandas 
Python :: moving file in python 
Python :: replace none with empty string python 
Python :: python json normalize 
Python :: how to define the name of your tkinter window 
Python :: 3 dimensional array in numpy 
Python :: python mode 
Python :: hot to check tkinter verionin python 
Python :: find factorial in python 
Python :: pandas date range 
Python :: Calculate Euclidean Distance in Python using distance.euclidean() 
Python :: Python NumPy repeat Function Syntax 
Python :: read file contents python 
Python :: python show charracter code 
Python :: capwords python 
Python :: how to install api in python 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =