推荐学习书目
› 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
vtoexsir
V2EX  ›  Python

怎么查看 Beautiful Soup 的 prettify(encoding, formatter="minimal")第二个参数有哪些合法的取值?

  •  
  •   vtoexsir · Mar 18, 2017 · 2608 views
    This topic created in 3478 days ago, the information mentioned may be changed or developed.

    soup=bs(html)
    soup.prettify(encoding=None, formatter='minimal')

    prettify()方法的第二个参数 formatter 到底有几个合法的取值呢?
    我们只知道有 minimal,还有什么呢?我们都不知道.
    怎么找到这些参数的值呢?
    这是 python 最不好的一个地方,方法的说明里不写明白,使用者怎么寻找这些特定的取值呢?

    4 replies  •  2017-03-18 18:07:22 +08:00
    sampeng
        1
    sampeng  
       Mar 18, 2017
    这个锅 python 不背。。。开发者不写注释神仙也没办法啊
    kindjeff
        2
    kindjeff  
       Mar 18, 2017   ❤️ 1
    哇,我怎么一看就在官方文档里看见了。

    https://www.crummy.com/software/BeautifulSoup/bs4/doc/#output-formatters
    vtoexsir
        3
    vtoexsir  
    OP
       Mar 18, 2017
    @kindjeff 是的,一点一点查看文档,翻遍了,自然能找到.
    但通常使用者不是这样使用的.比如我使用 pycharm,
    通常我看到代码提示,但不知道具体参数什么意思,于是找到方法定义的地方,
    但还是没有 formatter 的具体内容,再找 pycharm 就无能为力了!
    我想问的是,不一点点的翻文档,怎么使用 pycharm 这样的工具就能方便的找到 formatter 的具体值有哪些?
    kindjeff
        4
    kindjeff  
       Mar 18, 2017   ❤️ 1
    @vtoexsir 把光标移到函数名的位置,按一下 ctrl+Q 看文档。没有的话就只能再去找官方文档了。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   949 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 18:48 · PVG 02:48 · LAX 11:48 · JFK 14:48
    ♥ Do have faith in what you're doing.