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
vtoexsir
V2EX  ›  Python

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

  •  
  •   vtoexsir · 2017-03-18 16:44:23 +08:00 · 1795 次点击
    这是一个创建于 2595 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

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

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

    https://www.crummy.com/software/BeautifulSoup/bs4/doc/#output-formatters
    vtoexsir
        3
    vtoexsir  
    OP
       2017-03-18 17:29:14 +08:00
    @kindjeff 是的,一点一点查看文档,翻遍了,自然能找到.
    但通常使用者不是这样使用的.比如我使用 pycharm,
    通常我看到代码提示,但不知道具体参数什么意思,于是找到方法定义的地方,
    但还是没有 formatter 的具体内容,再找 pycharm 就无能为力了!
    我想问的是,不一点点的翻文档,怎么使用 pycharm 这样的工具就能方便的找到 formatter 的具体值有哪些?
    kindjeff
        4
    kindjeff  
       2017-03-18 18:07:22 +08:00   ❤️ 1
    @vtoexsir 把光标移到函数名的位置,按一下 ctrl+Q 看文档。没有的话就只能再去找官方文档了。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3197 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 13:58 · PVG 21:58 · LAX 06:58 · JFK 09:58
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.