没有项目描述
oprint的Python项目详细描述
cpython 3.6dict对象的pprint保持插入顺序。
关于
cpython 3.6为dict对象使用了一个新的“紧凑”表示。作为一个 很好的副作用这会保留键的插入顺序。
The order-preserving aspect of this new implementation is considered an implementation detail and should not be relied upon
pprint.pprint()保留了它在早期python版本中的行为。 它通过按字母顺序排序键来格式化dict对象。
>>>importpprint>>>pprint.pprint({'foo':1,'bar':2,'baz':3}){'bar':2,'baz':3,'foo':1}
oprint.pprint()扔掉旧的。
>>>importoprint>>>oprint.pprint({'foo':1,'bar':2,'baz':3}){'foo':1,'bar':2,'baz':3}
否则,库是pprint的替换项。
安装
pip install oprint