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

如何解析非命令行输入的命令式文本?

  •  
  •   Candyhorse · Mar 21, 2013 · 4195 views
    This topic created in 4975 days ago, the information mentioned may be changed or developed.
    类似这样的命令:

    post search v2ex
    post search -a Livid
    ……

    不是从命令行输入,而是用户从网页端输入

    根据不同的命令,匹配不同的处理逻辑

    除了手工正则匹配外,有没有能够更方便地处理类似情况的模块?

    谢谢:)
    5 replies  •  1970-01-01 08:00:00 +08:00
    YUCOAT
    YUCOAT
    Mar 22, 2013 via Android
    1
    不太明白你的意思
    undeflife
    undeflife
    Mar 22, 2013
    2
    OptionParser
    hit9
    hit9
    Mar 22, 2013❤️1
    3
    docopt 不错的。
    Candyhorse
    Candyhorse
    OP
    Mar 22, 2013
    4
    @hit9

    very nice ~

    不知道 Python 自带的 argparser 能不能完成类似的任务?
    huangzxx
    huangzxx
    Mar 22, 2013
    5
    argparser 是推荐用的,optparse 已经 deprecated
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1953 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 16:46 · PVG 00:46 · LAX 08:46 · JFK 11:46
    ♥ Do have faith in what you're doing.