一个轻量级的嵌套打印,用于函数内循环中的所有函数
nprint的Python项目详细描述
轻量级嵌套打印,用于 功能需求
安装
您可以使用pip安装
pip3 install --user nested_print
用法
这个函数类似于python打印api的扩展,因此您可以使用 end和sep以及print API中列出的所有内容。只有 添加其他字段:
- 水平
- 嵌套
基本示例
fromnested_printimportnprintnprint("hi","there",level=2)# prints \t\t hi therenprint("hi","there",level=1,nest="--")# prints -- hi there
动机示例
fromnested_printimportnprintnprint("here")foriinrange(10):nprint(i,level=1)forjinrange(3):nprint(j,level=2)
哪个打印
here 00121012 ...
因此,我更容易调试
api
水平
这描述了要添加多少“嵌套”或“缩进”。设置 level=0与使用print相同。level=1缩进输出 一次,打印时在前面添加\t。
嵌套
默认情况下,nest设置为\t。如果需要,可以设置此值 修改缩进。例如,不使用\t,您可以 将nest=" "设置为只添加2个空格作为缩进。或设置 nest="--"为每个缩进设置两个破折号。
版本
1.0.x*原始发布及其修复