推荐学习书目
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 · Sep 13, 2016 · 2918 views
    This topic created in 3557 days ago, the information mentioned may be changed or developed.

    https://github.com/panyanyany/beeprint

    print 某个 object 效果如下:

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

    1

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

    6 replies    2016-09-17 20:13:45 +08:00
    bazingaterry
        1
    bazingaterry  
       Sep 13, 2016
    目测调试的时候很实用,已 Star 。
    panyanyany
        2
    panyanyany  
    OP
       Sep 14, 2016
    @bazingaterry 谢谢,我也主要是调试的时候用的!
    guyskk
        3
    guyskk  
       Sep 14, 2016
    ```
    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
       Sep 14, 2016
    r#3 @guyskk 好的,我改进下!
    leavic
        5
    leavic  
       Sep 14, 2016
    好东西
    mingyun
        6
    mingyun  
       Sep 17, 2016
    star
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3708 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 00:46 · PVG 08:46 · LAX 17:46 · JFK 20:46
    ♥ Do have faith in what you're doing.