V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
panyanyany
V2EX  ›  Python

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

  •  1
     
  •   panyanyany · 2016-09-13 22:35:02 +08:00 · 2420 次点击
    这是一个创建于 2783 天前的主题,其中的信息可能已经有所发展或是发生改变。

    https://github.com/panyanyany/beeprint

    print 某个 object 效果如下:

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

    1

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

    6 条回复    2016-09-17 20:13:45 +08:00
    bazingaterry
        1
    bazingaterry  
       2016-09-13 23:44:11 +08:00
    目测调试的时候很实用,已 Star 。
    panyanyany
        2
    panyanyany  
    OP
       2016-09-14 00:08:33 +08:00
    @bazingaterry 谢谢,我也主要是调试的时候用的!
    guyskk
        3
    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
        4
    panyanyany  
    OP
       2016-09-14 10:00:59 +08:00
    r#3 @guyskk 好的,我改进下!
    leavic
        5
    leavic  
       2016-09-14 11:21:51 +08:00
    好东西
    mingyun
        6
    mingyun  
       2016-09-17 20:13:45 +08:00
    star
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   882 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 21:55 · PVG 05:55 · LAX 14:55 · JFK 17:55
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.