Python 3.5
Python 3.6 (OrderedDict)
PythonPython3.7

( dict )( OrderedDict )使

dict
OrderedDict
OrderedDict dict
OrderedDict


OrderedDict
OrderedDict popitem()
OrderedDict move_to_end()

popitem() dict ( OrderedDict )FIFO(First-In First-Out: ) LIFO(Last-In First-Out: last=<True|False>
from collections import OrderedDict
d = {'b': 1, 'a': 2, 'c':3}
k,v=d.popitem()
print(type(d))
print(k,v)
print(d.items())
od = OrderedDict([('b', 1), ('a', 2), ('c',3)])
k,v=od.popitem(last=False)
print(type(od))
print(k,v)
print(od.items())
od = OrderedDict([('b', 1), ('a', 2), ('c',3)])
k,v=od.popitem(last=True)
print(type(od))
print(k,v)
print(od.items())

$ python 0222_ordereddict.py
<class 'dict'>
c 3
dict_items([('b', 1), ('a', 2)])
<class 'collections.OrderedDict'>
b 1
odict_items([('a', 2), ('c', 3)])
<class 'collections.OrderedDict'>
c 3
odict_items([('b', 1), ('a', 2)])


previous: