程序员节来临,默默奉献个比 pprint 好用得多的神器

2016-09-13 22:35:02 +08:00
 panyanyany

https://github.com/panyanyany/beeprint

print 某个 object 效果如下:

其中 cleaned_text 中的文本有几十行,本程序自动进行了剪裁,只显示前 3 行。

这里有更详细的文档: https://github.com/panyanyany/beeprint

2442 次点击
所在节点    Python
6 条回复
bazingaterry
2016-09-13 23:44:11 +08:00
目测调试的时候很实用,已 Star 。
panyanyany
2016-09-14 00:08:33 +08:00
@bazingaterry 谢谢,我也主要是调试的时候用的!
guyskk
2016-09-14 00:20:57 +08:00
```
Python 3.5.2 (default, Jun 28 2016, 08:46:01)
[GCC 6.1.1 20160602] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from beeprint import pp
>>> d = {
... }
>>> d['d'] = d
>>> d
{'d': {...}}
>>> pp(d)
{
'd': {
'd': {
'd': {
'd': {
'd': {'d': {...}},
},
},
},
},
}
"{\n 'd': {\n 'd': {\n 'd': {\n 'd': {\n 'd': {'d': {...}},\n },\n },\n },\n },\n}\n"
>>>
>>> from pprint import pprint
>>> pprint(d)
{'d': <Recursion on dict with id=140001602555400>}
>>>
```
可以优化下这类特殊情况。
panyanyany
2016-09-14 10:00:59 +08:00
r#3 @guyskk 好的,我改进下!
leavic
2016-09-14 11:21:51 +08:00
好东西
mingyun
2016-09-17 20:13:45 +08:00
star

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/306043

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX