


Example of Python implementation of ordered dictionary method
Oct 04, 2017 am 09:25 AMThis article mainly introduces the simple implementation method of Python ordered dictionary, involving the related operation skills of Python using the OrderedDict method for dictionary sorting. Friends in need can refer to the following
The example of this article tells the Python ordered dictionary Simple implementation method. Share it with everyone for your reference, the details are as follows:
Code:
# -*- coding: UTF-8 -*- import collections print 'Regular dictionary:' d = {} d['a'] = 'A' d['b'] = 'B' d['c'] = 'C' for k, v in d.items(): print k, v print '\nOrderedDict:' d = collections.OrderedDict() d['a'] = 'A' d['b'] = 'B' d['c'] = 'C' for k, v in d.items(): print k, v
Execution result:
The above is the detailed content of Example of Python implementation of ordered dictionary method. For more information, please follow other related articles on the PHP Chinese website!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to set font size on mobile phone (easily adjust font size on mobile phone)

What are the advantages and disadvantages of templating?

Google AI announces Gemini 1.5 Pro and Gemma 2 for developers

How to choose a mobile phone screen protector to protect your mobile phone screen (several key points and tips for purchasing mobile phone screen protectors)
