pprint — 数据美化打印机

源代码: Lib/pprint.py


The pprint 模块提供可以用作解释器输入形式的 pretty-print (美化打印) 任意 Python 数据结构的能力。若格式化的结构包括非基础 Python 类型的对象,表示可能无法被加载。若是包括文件、套接字或类的对象及许多无法表示成 Python 文字的其它对象,可能属于此情况。

The formatted representation keeps objects on a single line if it can, and breaks them onto multiple lines if they don’t fit within the allowed width, adjustable by the width parameter defaulting to 80 characters.

字典按键排序在计算显示之前。

3.9 版改变: 添加支持为美化打印 types.SimpleNamespace .

3.10 版改变: 添加支持为美化打印 dataclasses.dataclass .