27 Jul
2018
27 Jul
'18
1:24 p.m.
27.07.18 12:53, Chris Angelico пише:
from collections import OrderedDict od = OrderedDict([('a', 1), ('b', 2)]) dict.__repr__(od) "{'a': 1, 'b': 2}"
dict.__repr__() can output items in wrong order.
from collections import OrderedDict od = OrderedDict([('a', 1), ('b', 2)]) od.move_to_end('a') print(repr(od)) OrderedDict([('b', 2), ('a', 1)]) print(dict.__repr__(od)) {'a': 1, 'b': 2}